huan233usc commented on code in PR #18494:
URL: https://github.com/apache/iceberg/pull/18494#discussion_r4396124373
##########
spark/v4.1/spark/src/main/java/org/apache/iceberg/spark/source/SyncSparkMicroBatchPlanner.java:
##########
@@ -234,6 +245,36 @@ public StreamingOffset latestOffset(StreamingOffset
startOffset, ReadLimit limit
return latestStreamingOffset.equals(startingOffset) ? null :
latestStreamingOffset;
}
+ // Computes latestOffset for an unbounded (allAvailable) limit without
per-file planning: the end
+ // offset is the latest valid snapshot's added-file count (or the
pre-computed
+ // Trigger.AvailableNow
+ // cap), reached by walking only the snapshot chain. See latestOffset for
the rationale.
+ private StreamingOffset latestOffsetForUnbounded(
+ StreamingOffset startingOffset, Snapshot curSnapshot) {
+ StreamingOffset latestStreamingOffset;
+ if (lastOffsetForTriggerAvailableNow != null) {
+ // Trigger.AvailableNow caps the run at a snapshot computed up front.
+ latestStreamingOffset = lastOffsetForTriggerAvailableNow;
+ } else {
+ // Advance the snapshot chain (metadata only) to the latest valid
snapshot.
+ Snapshot lastValidSnapshot = curSnapshot;
+ Snapshot next;
+ do {
+ next = nextValidSnapshot(lastValidSnapshot);
+ if (next != null) {
+ lastValidSnapshot = next;
+ }
+ } while (next != null);
+ latestStreamingOffset =
+ new StreamingOffset(
+ lastValidSnapshot.snapshotId(),
+ MicroBatchUtils.addedFilesCount(table(), lastValidSnapshot),
Review Comment:
Does `addedFilesCount` always match the end position? `MicroBatches`
includes existing files when computing manifest offsets. For manifests
`[added=1, existing=1]` and `[added=1]`, the added files are at positions 0 and
2, so returning 2 skips the second file. Could we add a test with merged
manifests?
--
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]