You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by "slfan1989 (via GitHub)" <gi...@apache.org> on 2025/04/12 02:25:15 UTC

[PR] Spark 3.5: Use ProcedureInput for SnapshotTableProcedure. [iceberg]

slfan1989 opened a new pull request, #12783:
URL: https://github.com/apache/iceberg/pull/12783

   Spark 3.5: Use ProcedureInput for SnapshotTableProcedure.


-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Spark 3.5: Use ProcedureInput for SnapshotTableProcedure. [iceberg]

Posted by "manuzhang (via GitHub)" <gi...@apache.org>.
manuzhang commented on code in PR #12783:
URL: https://github.com/apache/iceberg/pull/12783#discussion_r2047176411


##########
spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/procedures/SnapshotTableProcedure.java:
##########
@@ -104,8 +106,8 @@ public InternalRow[] call(InternalRow args) {
       action.tableLocation(snapshotLocation);
     }
 
-    if (!args.isNullAt(4)) {
-      int parallelism = args.getInt(4);
+    Integer parallelism = input.asInt(PARALLELISM_PARAM, null);
+    if (parallelism != null) {

Review Comment:
   Sorry, the equivalent change should be
   
   ```java
   if (input.isProvided(PARALLELISM_PARAM)) {
     int parallelism = input.asInt(PARALLELISM_PARAM);
     ...
   }
   ```



-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Spark 3.5: Use ProcedureInput for SnapshotTableProcedure. [iceberg]

Posted by "nastra (via GitHub)" <gi...@apache.org>.
nastra merged PR #12783:
URL: https://github.com/apache/iceberg/pull/12783


-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Spark 3.5: Use ProcedureInput for SnapshotTableProcedure. [iceberg]

Posted by "slfan1989 (via GitHub)" <gi...@apache.org>.
slfan1989 commented on code in PR #12783:
URL: https://github.com/apache/iceberg/pull/12783#discussion_r2047266140


##########
spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/procedures/SnapshotTableProcedure.java:
##########
@@ -104,8 +106,8 @@ public InternalRow[] call(InternalRow args) {
       action.tableLocation(snapshotLocation);
     }
 
-    if (!args.isNullAt(4)) {
-      int parallelism = args.getInt(4);
+    Integer parallelism = input.asInt(PARALLELISM_PARAM, null);
+    if (parallelism != null) {

Review Comment:
   Thanks for your suggestion! I have modified this part of the code.



-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Spark 3.5: Use ProcedureInput for SnapshotTableProcedure. [iceberg]

Posted by "manuzhang (via GitHub)" <gi...@apache.org>.
manuzhang commented on code in PR #12783:
URL: https://github.com/apache/iceberg/pull/12783#discussion_r2047089181


##########
spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/procedures/SnapshotTableProcedure.java:
##########
@@ -104,8 +106,8 @@ public InternalRow[] call(InternalRow args) {
       action.tableLocation(snapshotLocation);
     }
 
-    if (!args.isNullAt(4)) {
-      int parallelism = args.getInt(4);
+    Integer parallelism = input.asInt(PARALLELISM_PARAM, null);
+    if (parallelism != null) {

Review Comment:
   one liner `Preconditions.checkArgument(parallelism == null || parallelism > 0, "Parallelism should be larger than 0");`



-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Spark 3.5: Use ProcedureInput for SnapshotTableProcedure. [iceberg]

Posted by "nastra (via GitHub)" <gi...@apache.org>.
nastra commented on code in PR #12783:
URL: https://github.com/apache/iceberg/pull/12783#discussion_r2047317449


##########
spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/procedures/SnapshotTableProcedure.java:
##########
@@ -74,26 +81,21 @@ public StructType outputType() {
 
   @Override
   public InternalRow[] call(InternalRow args) {
-    String source = args.getString(0);
+

Review Comment:
   unnecessary newline here



-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Spark 3.5: Use ProcedureInput for SnapshotTableProcedure. [iceberg]

Posted by "slfan1989 (via GitHub)" <gi...@apache.org>.
slfan1989 commented on code in PR #12783:
URL: https://github.com/apache/iceberg/pull/12783#discussion_r2048102871


##########
spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/procedures/SnapshotTableProcedure.java:
##########
@@ -74,26 +81,21 @@ public StructType outputType() {
 
   @Override
   public InternalRow[] call(InternalRow args) {
-    String source = args.getString(0);
+

Review Comment:
   Thank you for reviewing the code! I will improve it.



-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Spark 3.5: Use ProcedureInput for SnapshotTableProcedure. [iceberg]

Posted by "nastra (via GitHub)" <gi...@apache.org>.
nastra commented on PR #12783:
URL: https://github.com/apache/iceberg/pull/12783#issuecomment-2811853778

   thanks @slfan1989 for improving this and @manuzhang for reviewing


-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Spark 3.5: Use ProcedureInput for SnapshotTableProcedure. [iceberg]

Posted by "manuzhang (via GitHub)" <gi...@apache.org>.
manuzhang commented on code in PR #12783:
URL: https://github.com/apache/iceberg/pull/12783#discussion_r2047089181


##########
spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/procedures/SnapshotTableProcedure.java:
##########
@@ -104,8 +106,8 @@ public InternalRow[] call(InternalRow args) {
       action.tableLocation(snapshotLocation);
     }
 
-    if (!args.isNullAt(4)) {
-      int parallelism = args.getInt(4);
+    Integer parallelism = input.asInt(PARALLELISM_PARAM, null);
+    if (parallelism != null) {

Review Comment:
   This can be simplified into `Preconditions.checkArgument(parallelism == null || parallelism > 0, "Parallelism should be larger than 0");`



-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Spark 3.5: Use ProcedureInput for SnapshotTableProcedure. [iceberg]

Posted by "slfan1989 (via GitHub)" <gi...@apache.org>.
slfan1989 commented on PR #12783:
URL: https://github.com/apache/iceberg/pull/12783#issuecomment-2811952630

   @nastra @manuzhang Thank you very much for reviewing the code!


-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Spark 3.5: Use ProcedureInput for SnapshotTableProcedure. [iceberg]

Posted by "slfan1989 (via GitHub)" <gi...@apache.org>.
slfan1989 commented on code in PR #12783:
URL: https://github.com/apache/iceberg/pull/12783#discussion_r2047150494


##########
spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/procedures/SnapshotTableProcedure.java:
##########
@@ -104,8 +106,8 @@ public InternalRow[] call(InternalRow args) {
       action.tableLocation(snapshotLocation);
     }
 
-    if (!args.isNullAt(4)) {
-      int parallelism = args.getInt(4);
+    Integer parallelism = input.asInt(PARALLELISM_PARAM, null);
+    if (parallelism != null) {

Review Comment:
   Thank you for your suggestion! Your modification has made the validation logic simpler. However, I have a small concern. `parallelism` may be null, but we must ensure that `parallelism != null` in order to execute `action = action.executeWith(SparkTableUtil.migrationService(parallelism))`. If `parallelism` is null, subsequent code may throw an exception.
   
   https://github.com/apache/iceberg/blob/013d09e473faada1a3b21c155964ec4d1254d69d/spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/SparkTableUtil.java#L990-L993



-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Spark 3.5: Use ProcedureInput for SnapshotTableProcedure. [iceberg]

Posted by "manuzhang (via GitHub)" <gi...@apache.org>.
manuzhang commented on code in PR #12783:
URL: https://github.com/apache/iceberg/pull/12783#discussion_r2045934050


##########
spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/procedures/SnapshotTableProcedure.java:
##########
@@ -104,11 +106,9 @@ public InternalRow[] call(InternalRow args) {
       action.tableLocation(snapshotLocation);
     }
 
-    if (!args.isNullAt(4)) {
-      int parallelism = args.getInt(4);
-      Preconditions.checkArgument(parallelism > 0, "Parallelism should be larger than 0");
-      action = action.executeWith(SparkTableUtil.migrationService(parallelism));
-    }
+    int parallelism = input.asInt(PARALLELISM_PARAM, 1);

Review Comment:
   Please do not change the previous default value, `null`.



-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Spark 3.5: Use ProcedureInput for SnapshotTableProcedure. [iceberg]

Posted by "slfan1989 (via GitHub)" <gi...@apache.org>.
slfan1989 commented on code in PR #12783:
URL: https://github.com/apache/iceberg/pull/12783#discussion_r2047058500


##########
spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/procedures/SnapshotTableProcedure.java:
##########
@@ -104,11 +106,9 @@ public InternalRow[] call(InternalRow args) {
       action.tableLocation(snapshotLocation);
     }
 
-    if (!args.isNullAt(4)) {
-      int parallelism = args.getInt(4);
-      Preconditions.checkArgument(parallelism > 0, "Parallelism should be larger than 0");
-      action = action.executeWith(SparkTableUtil.migrationService(parallelism));
-    }
+    int parallelism = input.asInt(PARALLELISM_PARAM, 1);

Review Comment:
   Thank you for reviewing the code! I've made the changes based on your suggestions.



-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Spark 3.5: Use ProcedureInput for SnapshotTableProcedure. [iceberg]

Posted by "slfan1989 (via GitHub)" <gi...@apache.org>.
slfan1989 commented on code in PR #12783:
URL: https://github.com/apache/iceberg/pull/12783#discussion_r2047173652


##########
spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/procedures/SnapshotTableProcedure.java:
##########
@@ -104,8 +106,8 @@ public InternalRow[] call(InternalRow args) {
       action.tableLocation(snapshotLocation);
     }
 
-    if (!args.isNullAt(4)) {
-      int parallelism = args.getInt(4);
+    Integer parallelism = input.asInt(PARALLELISM_PARAM, null);
+    if (parallelism != null) {

Review Comment:
   Can I modify it to the following this?
   
   ```
   Preconditions.checkArgument(parallelism == null || parallelism > 0, 
       "Parallelism should be larger than 0");
   if (parallelism != null) {
      action = action.executeWith(SparkTableUtil.migrationService(parallelism));
   }
   ```



-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org