You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by "rakesh-das08 (via GitHub)" <gi...@apache.org> on 2023/06/24 15:42:17 UTC

[GitHub] [iceberg] rakesh-das08 opened a new pull request, #7900: Fix Spark WAP branch not propagated when using DELETE without WHERE

rakesh-das08 opened a new pull request, #7900:
URL: https://github.com/apache/iceberg/pull/7900

   This is for resolving #7851 


-- 
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


[GitHub] [iceberg] RussellSpitzer commented on a diff in pull request #7900: Spark 3.4: WAP branch not propagated when using DELETE without WHERE

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


##########
spark/v3.4/spark/src/main/java/org/apache/iceberg/spark/SparkTableUtil.java:
##########
@@ -666,6 +667,34 @@ public static Dataset<Row> loadMetadataTable(
         spark, DataSourceV2Relation.create(metadataTable, Some.empty(), Some.empty(), options));
   }
 
+  public static String wapBranch(SparkSession spark, String branch) {

Review Comment:
   I don't think this is much clearer. What I think this method is more likely defined as "determine write branch?" It is not restricted to WAP and also validates the configuration of non WAP config? It seems like it handles multiple concerns 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


[GitHub] [iceberg] RussellSpitzer commented on a diff in pull request #7900: Spark 3.4: WAP branch not propagated when using DELETE without WHERE

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


##########
spark/v3.4/spark/src/main/java/org/apache/iceberg/spark/SparkTableUtil.java:
##########
@@ -666,6 +667,34 @@ public static Dataset<Row> loadMetadataTable(
         spark, DataSourceV2Relation.create(metadataTable, Some.empty(), Some.empty(), options));
   }
 
+  public static String wapBranch(SparkSession spark, String branch) {

Review Comment:
   Rather than having this function do both things we should probably have two functions.
   
   1. Validate configuration
   2. Choose branch
   
   In general if our javadoc says a function is doing two different things, it means that function needs to be split. 
   
   so code could look like
   ```java
   deleteWhere() {
      validateConfig
      
      
      branch = branch != null ? branch : wapBranch
      if (branch != null) {
        deleteFiles.toBranch(branch)
      }
   ```



-- 
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


[GitHub] [iceberg] RussellSpitzer commented on pull request #7900: Spark 3.4: WAP branch not propagated when using DELETE without WHERE

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

   @nastra told me this is matching the style used elsewhere, so let's merge for now and fix all of the style issues later in a followup. 


-- 
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


[GitHub] [iceberg] rakesh-das08 commented on pull request #7900: Spark: WAP branch not propagated when using DELETE without WHERE

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

   @nastra Could you please review


-- 
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


[GitHub] [iceberg] nastra commented on pull request #7900: Spark: WAP branch not propagated when using DELETE without WHERE

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

   @jackye1995 @aokolnychyi @RussellSpitzer could any of you also please review this?


-- 
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


[GitHub] [iceberg] RussellSpitzer commented on a diff in pull request #7900: Spark: WAP branch not propagated when using DELETE without WHERE

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


##########
spark/v3.4/spark/src/main/java/org/apache/iceberg/spark/SparkTableUtil.java:
##########
@@ -666,6 +667,34 @@ public static Dataset<Row> loadMetadataTable(
         spark, DataSourceV2Relation.create(metadataTable, Some.empty(), Some.empty(), options));
   }
 
+  public static String wapBranch(SparkSession spark, String branch) {

Review Comment:
   I'm not sure it's clear enough from this name what this method is doing, can we add a java doc or possibly a new name?
   
   Looks like it returns the WAP Branch if it is configured in the Spark conf and then the string that is passed in otherwise?



-- 
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


[GitHub] [iceberg] rakesh-das08 commented on pull request #7900: Spark: WAP branch not propagated when using DELETE without WHERE

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

   @nastra Thank you for reviewing this :)


-- 
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


[GitHub] [iceberg] rakesh-das08 commented on a diff in pull request #7900: Spark: WAP branch not propagated when using DELETE without WHERE

Posted by "rakesh-das08 (via GitHub)" <gi...@apache.org>.
rakesh-das08 commented on code in PR #7900:
URL: https://github.com/apache/iceberg/pull/7900#discussion_r1246696064


##########
spark/v3.4/spark-extensions/src/test/java/org/apache/iceberg/spark/extensions/TestDelete.java:
##########
@@ -1271,6 +1273,41 @@ public void testDeleteToWapBranchWithTableBranchIdentifier() throws NoSuchTableE
                         branch)));
   }
 
+  @Test
+  public void testDeleteToCustomWapBranchWithoutWhereClause() throws NoSuchTableException {
+    assumeThat(branch != null && !branch.equals(SnapshotRef.MAIN_BRANCH))

Review Comment:
   Done



##########
spark/v3.4/spark/src/main/java/org/apache/iceberg/spark/SparkTableUtil.java:
##########
@@ -666,6 +667,36 @@ public static Dataset<Row> loadMetadataTable(
         spark, DataSourceV2Relation.create(metadataTable, Some.empty(), Some.empty(), options));
   }
 
+  public static String wapBranch(SparkSession spark, String branch) {
+    String wapId = spark.conf().get(SparkSQLProperties.WAP_ID, null);
+    String wapBranch = spark.conf().get(SparkSQLProperties.WAP_BRANCH, null);
+    ValidationException.check(
+        wapId == null || wapBranch == null,
+        "Cannot set both WAP ID and branch, but got ID [%s] and branch [%s]",
+        wapId,
+        wapBranch);
+
+    if (wapBranch != null) {
+      ValidationException.check(
+          branch == null,
+          "Cannot write to both branch and WAP branch, but got branch [%s] and WAP branch [%s]",
+          branch,
+          wapBranch);
+
+      return wapBranch;
+    }
+    return branch;
+  }
+
+  public static boolean wapEnabled(Table table) {
+    return Boolean.parseBoolean(

Review Comment:
   Done



-- 
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


[GitHub] [iceberg] rakesh-das08 commented on a diff in pull request #7900: Spark 3.4: WAP branch not propagated when using DELETE without WHERE

Posted by "rakesh-das08 (via GitHub)" <gi...@apache.org>.
rakesh-das08 commented on code in PR #7900:
URL: https://github.com/apache/iceberg/pull/7900#discussion_r1252181216


##########
spark/v3.4/spark/src/main/java/org/apache/iceberg/spark/SparkTableUtil.java:
##########
@@ -666,6 +667,34 @@ public static Dataset<Row> loadMetadataTable(
         spark, DataSourceV2Relation.create(metadataTable, Some.empty(), Some.empty(), options));
   }
 
+  public static String wapBranch(SparkSession spark, String branch) {

Review Comment:
   Thanks @RussellSpitzer .
   Would request your review once more. Made some changes in Javadoc



-- 
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


[GitHub] [iceberg] rakesh-das08 commented on a diff in pull request #7900: Spark 3.4: WAP branch not propagated when using DELETE without WHERE

Posted by "rakesh-das08 (via GitHub)" <gi...@apache.org>.
rakesh-das08 commented on code in PR #7900:
URL: https://github.com/apache/iceberg/pull/7900#discussion_r1250387923


##########
spark/v3.4/spark/src/main/java/org/apache/iceberg/spark/SparkTableUtil.java:
##########
@@ -666,6 +667,34 @@ public static Dataset<Row> loadMetadataTable(
         spark, DataSourceV2Relation.create(metadataTable, Some.empty(), Some.empty(), options));
   }
 
+  public static String wapBranch(SparkSession spark, String branch) {

Review Comment:
   HI Russell, I have added Javadoc for this method. Please review.



-- 
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


[GitHub] [iceberg] nastra commented on a diff in pull request #7900: Spark: WAP branch not propagated when using DELETE without WHERE

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


##########
spark/v3.4/spark-extensions/src/test/java/org/apache/iceberg/spark/extensions/TestDelete.java:
##########
@@ -1271,6 +1273,41 @@ public void testDeleteToWapBranchWithTableBranchIdentifier() throws NoSuchTableE
                         branch)));
   }
 
+  @Test
+  public void testDeleteToCustomWapBranchWithoutWhereClause() throws NoSuchTableException {
+    assumeThat(branch != null && !branch.equals(SnapshotRef.MAIN_BRANCH))

Review Comment:
   ```suggestion
       assumeThat(branch)
           .as("Run only if custom WAP branch is not main")
           .isNotNull()
           .isNotEqualTo(SnapshotRef.MAIN_BRANCH);
   ```



##########
spark/v3.4/spark/src/main/java/org/apache/iceberg/spark/SparkTableUtil.java:
##########
@@ -666,6 +667,36 @@ public static Dataset<Row> loadMetadataTable(
         spark, DataSourceV2Relation.create(metadataTable, Some.empty(), Some.empty(), options));
   }
 
+  public static String wapBranch(SparkSession spark, String branch) {
+    String wapId = spark.conf().get(SparkSQLProperties.WAP_ID, null);
+    String wapBranch = spark.conf().get(SparkSQLProperties.WAP_BRANCH, null);
+    ValidationException.check(
+        wapId == null || wapBranch == null,
+        "Cannot set both WAP ID and branch, but got ID [%s] and branch [%s]",
+        wapId,
+        wapBranch);
+
+    if (wapBranch != null) {
+      ValidationException.check(
+          branch == null,
+          "Cannot write to both branch and WAP branch, but got branch [%s] and WAP branch [%s]",
+          branch,
+          wapBranch);
+
+      return wapBranch;
+    }
+    return branch;
+  }
+
+  public static boolean wapEnabled(Table table) {
+    return Boolean.parseBoolean(

Review Comment:
   ```suggestion
       return PropertyUtil.propertyAsBoolean(
           table.properties(),
           TableProperties.WRITE_AUDIT_PUBLISH_ENABLED,
           Boolean.getBoolean(TableProperties.WRITE_AUDIT_PUBLISH_ENABLED_DEFAULT));
   ```



-- 
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


[GitHub] [iceberg] RussellSpitzer commented on pull request #7900: Spark: WAP branch not propagated when using DELETE without WHERE

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

   Note I think this pr should also be title Spark 3.4: 
   Since we'll need to backport it to the other spark versions I assume


-- 
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


[GitHub] [iceberg] rakesh-das08 commented on pull request #7900: Spark 3.4: WAP branch not propagated when using DELETE without WHERE

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

   @RussellSpitzer, could you please review. Made changes as per your review comments.


-- 
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


[GitHub] [iceberg] nastra commented on pull request #7900: Spark 3.4: WAP branch not propagated when using DELETE without WHERE

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

   @RussellSpitzer could you please re-review this one? I think it would be great to get this into 1.3.1


-- 
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


[GitHub] [iceberg] RussellSpitzer commented on a diff in pull request #7900: Spark 3.4: WAP branch not propagated when using DELETE without WHERE

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


##########
spark/v3.4/spark-extensions/src/test/java/org/apache/iceberg/spark/extensions/TestDelete.java:
##########
@@ -1271,6 +1273,42 @@ public void testDeleteToWapBranchWithTableBranchIdentifier() throws NoSuchTableE
                         branch)));
   }
 
+  @Test
+  public void testDeleteToCustomWapBranchWithoutWhereClause() throws NoSuchTableException {
+    assumeThat(branch)

Review Comment:
   Why do we have this assumption? Shouldn't this be something we are configuring in the test?



-- 
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


[GitHub] [iceberg] rakesh-das08 commented on pull request #7900: Spark 3.4: WAP branch not propagated when using DELETE without WHERE

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

   Thank you @RussellSpitzer for reviewing this and merging.
   Thank you @nastra for reviewing this and getting this merged with clarifications. Appreciate 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


[GitHub] [iceberg] RussellSpitzer merged pull request #7900: Spark 3.4: WAP branch not propagated when using DELETE without WHERE

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


-- 
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