JingsongLi commented on code in PR #11421:
URL: https://github.com/apache/paimon/pull/11421#discussion_r4690254468


##########
paimon-core/src/main/java/org/apache/paimon/iceberg/IcebergCommitCallback.java:
##########
@@ -563,9 +563,16 @@ private void createMetadataWithoutBase(
         List<IcebergPartitionField> partitionFields =
                 getPartitionFields(table.schema().partitionKeys(), 
icebergSchema);
 
+        // the with-base path derives the operation from the commit kind; a 
rebuild exporting
+        // the full table must do the same, or incremental consumers replay it 
as new data
+        String operation = IcebergSnapshotSummary.APPEND.operation();
+        if (paimonSnapshot.commitKind() == Snapshot.CommitKind.COMPACT) {
+            operation = IcebergSnapshotSummary.REPLACE.operation();
+        } else if (paimonSnapshot.commitKind() == 
Snapshot.CommitKind.OVERWRITE) {
+            operation = IcebergSnapshotSummary.OVERWRITE.operation();

Review Comment:
   On a new append table with Iceberg publishing enabled, use `INSERT 
OVERWRITE` for the first write. The Iceberg snapshot has no parent and only 
adds data files. Marking it `overwrite` makes `newIncrementalAppendScan()` skip 
the inserted rows. Keep `append` for the initial snapshot when it only adds 
data files.



##########
paimon-core/src/main/java/org/apache/paimon/iceberg/IcebergCommitCallback.java:
##########
@@ -563,9 +563,16 @@ private void createMetadataWithoutBase(
         List<IcebergPartitionField> partitionFields =
                 getPartitionFields(table.schema().partitionKeys(), 
icebergSchema);
 
+        // the with-base path derives the operation from the commit kind; a 
rebuild exporting
+        // the full table must do the same, or incremental consumers replay it 
as new data
+        String operation = IcebergSnapshotSummary.APPEND.operation();
+        if (paimonSnapshot.commitKind() == Snapshot.CommitKind.COMPACT) {
+            operation = IcebergSnapshotSummary.REPLACE.operation();

Review Comment:
   On a primary-key table with deletion vectors disabled, publish an empty 
Iceberg snapshot, append rows that stay in L0, delete the Iceberg metadata 
directory, and run a full compaction. The rebuilt snapshot exposes the new rows 
in a full scan. An incremental append scan using 
`fromSnapshotExclusive(previousSnapshotId)` skips them because the snapshot is 
marked `replace`. Reserve `replace` for compactions that preserve the 
Iceberg-visible row set. If the prior Iceberg state is unavailable, make the 
rebuild require a full resync.



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