szehon-ho commented on a change in pull request #2925:
URL: https://github.com/apache/iceberg/pull/2925#discussion_r796966536



##########
File path: core/src/main/java/org/apache/iceberg/BaseReplacePartitions.java
##########
@@ -53,6 +60,24 @@ public ReplacePartitions validateAppendOnly() {
     return this;
   }
 
+  @Override
+  public ReplacePartitions validateFromSnapshot(long newStartingSnapshotId) {
+    this.startingSnapshotId = newStartingSnapshotId;
+    return this;
+  }
+
+  @Override
+  public void validate(TableMetadata currentMetadata) {
+    if (startingSnapshotId != null && startingSnapshotId != 0) {
+      if (dataSpec().isUnpartitioned()) {

Review comment:
       This is tricky, but I am thinking we should validate everything, 
consistent with the current behavior as you mention in next comment (if 
unpartition, replace everything).  From the spark side it makes sense to me 
that a user running "insert overwrite" on a currently-unpartitioned table will 
expect to replace all the data whether they are in now-useless old partitioned 
folders or the new one, so the validation check should be the whole table.  
(Unless we want to change base behavior)

##########
File path: core/src/main/java/org/apache/iceberg/BaseReplacePartitions.java
##########
@@ -53,6 +60,24 @@ public ReplacePartitions validateAppendOnly() {
     return this;
   }
 
+  @Override
+  public ReplacePartitions validateFromSnapshot(long newStartingSnapshotId) {
+    this.startingSnapshotId = newStartingSnapshotId;
+    return this;
+  }
+
+  @Override
+  public void validate(TableMetadata currentMetadata) {
+    if (startingSnapshotId != null && startingSnapshotId != 0) {
+      if (dataSpec().isUnpartitioned()) {

Review comment:
       This is tricky, but I am thinking we should validate everything, 
consistent with the current behavior as you mention in next comment (if 
currently unpartition, replace everything).  From the spark side it makes sense 
to me that a user running "insert overwrite" on a currently-unpartitioned table 
will expect to replace all the data whether they are in now-useless old 
partitioned folders or the new one, so the validation check should be the whole 
table.  (Unless we want to change base behavior)




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



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to