Skip to content

Commit

Permalink
fix bugs related to scan.timestamp-millis
Browse files Browse the repository at this point in the history
  • Loading branch information
yunfengzhou-hub committed Feb 12, 2025
1 parent d3d673d commit 86fb5b5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,8 @@ public Result scan(SnapshotReader reader) {
|| endTimestamp < earliestSnapshot.timeMillis()) {
return new NoSnapshot();
}
// in org.apache.paimon.utils.SnapshotManager.earlierOrEqualTimeMills
// 1. if earliestSnapshotId or latestSnapshotId is null startingSnapshotId will be null
// 2. if earliestSnapShot.timeMillis() > startTimestamp startingSnapshotId will be
// earliestSnapShotId
// if earliestSnapShot.timeMillis() > startTimestamp we should include the earliestSnapShot
// data
Long startSnapshotId =
(startingSnapshotId == null || earliestSnapshot.timeMillis() > startTimestamp)
? earliestSnapshot.id() - 1
: startingSnapshotId;
(startingSnapshotId == null) ? earliestSnapshot.id() - 1 : startingSnapshotId;
Snapshot endSnapshot = snapshotManager.earlierOrEqualTimeMills(endTimestamp);
Long endSnapshotId = (endSnapshot == null) ? latestSnapshot.id() : endSnapshot.id();
IncrementalStartingScanner incrementalStartingScanner =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,16 @@ public SnapshotReader configure(SnapshotReader snapshotReader) {

@Nullable
public static Snapshot timeTravelToTimestamp(SnapshotManager snapshotManager, long timestamp) {
return snapshotManager.earlierOrEqualTimeMills(timestamp);
Snapshot snapshot = snapshotManager.earlierOrEqualTimeMills(timestamp);
if (snapshot == null) {
Long earliest = snapshotManager.earliestSnapshotId();
if (earliest != null) {
Snapshot earliestSnapShot = snapshotManager.snapshot(earliest);
if (earliestSnapShot.timeMillis() > timestamp) {
snapshot = earliestSnapShot;
}
}
}
return snapshot;
}
}

0 comments on commit 86fb5b5

Please sign in to comment.