-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Core, API: Support scanning from refs #5364
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -39,13 +39,25 @@ public interface TableScan extends Scan<TableScan, FileScanTask, CombinedScanTas | |
| */ | ||
| TableScan useSnapshot(long snapshotId); | ||
|
|
||
| /** | ||
| * Create a new {@link TableScan} from this scan's configuration that will use the given | ||
| * reference. | ||
| * | ||
| * @param ref reference | ||
| * @return a new scan based on the given reference. | ||
| * @throws IllegalArgumentException if a reference with the given name could not be found | ||
| */ | ||
| TableScan useRef(String ref); | ||
|
|
||
| /** | ||
| * Create a new {@link TableScan} from this scan's configuration that will use the most recent | ||
| * snapshot as of the given time in milliseconds. | ||
| * snapshot as of the given time in milliseconds on the branch in the scan or main if no branch is | ||
| * set. | ||
| * | ||
| * @param timestampMillis a timestamp in milliseconds. | ||
| * @return a new scan based on this with the current snapshot at the given time | ||
| * @throws IllegalArgumentException if the snapshot cannot be found | ||
| * @throws IllegalArgumentException if the snapshot cannot be found or time travel is attempted on | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the doc change here is no longer needed? |
||
| * a tag | ||
| */ | ||
| TableScan asOfTime(long timestampMillis); | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -87,7 +87,7 @@ public TableScan appendsAfter(long fromSnapshotId) { | |
| @Override | ||
| public TableScan useSnapshot(long scanSnapshotId) { | ||
| Preconditions.checkArgument( | ||
| snapshotId() == null, "Cannot override snapshot, already set to id=%s", snapshotId()); | ||
| snapshotId() == null, "Cannot override snapshot, already set snapshot id=%s", snapshotId()); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: "set to snapshot id=%s"? |
||
| Preconditions.checkArgument( | ||
| tableOps().current().snapshot(scanSnapshotId) != null, | ||
| "Cannot find snapshot with ID %s", | ||
|
|
@@ -96,10 +96,20 @@ public TableScan useSnapshot(long scanSnapshotId) { | |
| tableOps(), table(), tableSchema(), context().useSnapshotId(scanSnapshotId)); | ||
| } | ||
|
|
||
| @Override | ||
| public TableScan useRef(String name) { | ||
amogh-jahagirdar marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| Preconditions.checkArgument( | ||
| snapshotId() == null, "Cannot override ref, already set snapshot id=%s", snapshotId()); | ||
| Snapshot snapshot = table().snapshot(name); | ||
| Preconditions.checkArgument(snapshot != null, "Cannot find ref %s", name); | ||
| return newRefinedScan( | ||
| tableOps(), table(), tableSchema(), context().useSnapshotId(snapshot.snapshotId())); | ||
| } | ||
|
|
||
| @Override | ||
| public TableScan asOfTime(long timestampMillis) { | ||
| Preconditions.checkArgument( | ||
| snapshotId() == null, "Cannot override snapshot, already set to id=%s", snapshotId()); | ||
| snapshotId() == null, "Cannot override snapshot, already set snapshot id=%s", snapshotId()); | ||
|
|
||
| return useSnapshot(SnapshotUtil.snapshotIdAsOfTime(table(), timestampMillis)); | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -46,6 +46,14 @@ public TableScan asOfTime(long timestampMillis) { | |
| timestampMillis, context().fromSnapshotId(), context().toSnapshotId())); | ||
| } | ||
|
|
||
| @Override | ||
| public TableScan useRef(String ref) { | ||
| throw new UnsupportedOperationException( | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems fine for now, but we may have a case where we want incremental to be able to specify a branch. It doesn't matter currently because the snapshot IDs are always explicit. |
||
| String.format( | ||
| "Cannot scan table using ref %s: configured for incremental data in snapshots (%s, %s]", | ||
| ref, context().fromSnapshotId(), context().toSnapshotId())); | ||
| } | ||
|
|
||
| @Override | ||
| public TableScan useSnapshot(long scanSnapshotId) { | ||
| throw new UnsupportedOperationException( | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: use the snapshot ID of the given reference?