askwang commented on code in PR #4657:
URL: https://github.com/apache/paimon/pull/4657#discussion_r1889626237


##########
paimon-spark/paimon-spark-common/src/main/java/org/apache/paimon/spark/procedure/ExpireSnapshotsProcedure.java:
##########
@@ -76,29 +80,22 @@ public InternalRow[] call(InternalRow args) {
         Integer retainMin = args.isNullAt(2) ? null : args.getInt(2);
         String olderThanStr = args.isNullAt(3) ? null : args.getString(3);
         Integer maxDeletes = args.isNullAt(4) ? null : args.getInt(4);
+        String options = args.isNullAt(5) ? null : args.getString(5);
 
         return modifyPaimonTable(
                 tableIdent,
                 table -> {
-                    ExpireSnapshots expireSnapshots = 
table.newExpireSnapshots();
-                    ExpireConfig.Builder builder = ExpireConfig.builder();
-                    if (retainMax != null) {
-                        builder.snapshotRetainMax(retainMax);
-                    }
-                    if (retainMin != null) {
-                        builder.snapshotRetainMin(retainMin);
-                    }
-                    if (!StringUtils.isNullOrWhitespaceOnly(olderThanStr)) {
-                        long olderThanMills =
-                                DateTimeUtils.parseTimestampData(
-                                                olderThanStr, 3, 
TimeZone.getDefault())
-                                        .getMillisecond();
-                        builder.snapshotTimeRetain(
-                                Duration.ofMillis(System.currentTimeMillis() - 
olderThanMills));
-                    }
-                    if (maxDeletes != null) {
-                        builder.snapshotMaxDeletes(maxDeletes);
+                    Map<String, String> dynamicOptions = new HashMap<>();
+                    if (!StringUtils.isNullOrWhitespaceOnly(options)) {
+                        
dynamicOptions.putAll(ParameterUtils.parseCommaSeparatedKeyValues(options));
                     }
+                    table = table.copy(dynamicOptions);
+                    ExpireSnapshots expireSnapshots = 
table.newExpireSnapshots();
+
+                    CoreOptions tableOptions = ((FileStoreTable) 
table).store().options();
+                    ExpireConfig.Builder builder =
+                            ProcedureUtils.fillInSnapshotOptions(
+                                    tableOptions, retainMax, retainMin, 
olderThanStr, maxDeletes);
                     int deleted = 
expireSnapshots.config(builder.build()).expire();

Review Comment:
   Yes, you are right. We should not update properties using the builder after 
`table.newExpireSnapshots()` which should included in dynamicOptions.
   
   I will remove the builder way in another pr, WDYT? @Zouxxyy 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to