Guosmilesmile commented on code in PR #19115:
URL: https://github.com/apache/iceberg/pull/19115#discussion_r4690641204


##########
flink/v2.3/flink/src/main/java/org/apache/iceberg/flink/source/lookup/IcebergLookupReader.java:
##########
@@ -91,6 +98,62 @@ CloseableIterable<RowData> read(long snapshotId) {
     return new LookupIterable(scan.planTasks(), fileReader);
   }
 
+  CloseableIterable<RowData> readDelta(long fromExclusive, long toInclusive) {
+    if (fromExclusive == toInclusive) {
+      return CloseableIterable.empty();
+    }
+
+    RowDataFileScanTaskReader fileReader =
+        new RowDataFileScanTaskReader(
+            SnapshotUtil.schemaFor(table, toInclusive),
+            projectedSchema,
+            nameMapping,
+            caseSensitive,
+            baseFilters);
+
+    IncrementalAppendScan appendScan =
+        table
+            .newIncrementalAppendScan()
+            .fromSnapshotExclusive(fromExclusive)
+            .toSnapshot(toInclusive)
+            .caseSensitive(caseSensitive)
+            .project(projectedSchema)
+            .filter(filter);
+
+    return new LookupIterable(appendScan.planTasks(), fileReader);
+  }
+
+  boolean isAppendOnlyRange(long fromExclusive, long toInclusive) {
+    if (fromExclusive == toInclusive
+        || fromExclusive == NO_SNAPSHOT_ID
+        || toInclusive == NO_SNAPSHOT_ID) {
+      return false;
+    }
+
+    try {
+      if (!SnapshotUtil.isAncestorOf(table, toInclusive, fromExclusive)) {
+        return false;
+      }
+
+      for (Snapshot snapshot :
+          SnapshotUtil.ancestorsBetween(toInclusive, fromExclusive, 
table::snapshot)) {
+        String operation = snapshot.operation();
+        if (!DataOperations.APPEND.equals(operation) && 
!DataOperations.REPLACE.equals(operation)) {

Review Comment:
   I use IncrementalAppendScan in readDelta, which only reads APPEND snapshots 
and skips REPLACE snapshots.
   
   isAppendOnlyRange is only used to determine whether we can perform an 
incremental scan. If we remove REPLACE from this part, we would have to fall 
back to a full load, which is not what we want.



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