Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,15 @@ protected Map<String, String> rewriteOtherOptions(Map<String, String> options) {
// then convert millisecond to other branch snapshot id
String scanSnapshotIdOptionKey = CoreOptions.SCAN_SNAPSHOT_ID.key();
String scanSnapshotId = options.get(scanSnapshotIdOptionKey);
String scanVersionOptionKey = CoreOptions.SCAN_VERSION.key();
String scanVersion = options.get(scanVersionOptionKey);
if (scanSnapshotId == null
&& scanVersion != null
&& scanVersion.chars().allMatch(Character::isDigit)
&& !wrapped.tagManager().tagExists(scanVersion)) {
scanSnapshotId = scanVersion;
result.remove(scanVersionOptionKey);
}
if (scanSnapshotId != null) {
long id = Long.parseLong(scanSnapshotId);
long millis = wrapped.snapshotManager().snapshot(id).timeMillis();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,30 @@ public void testPlanAndReadWithQueryAuthSplit() throws Exception {
assertThat(result).containsExactlyInAnyOrder(Pair.of(1, 1), Pair.of(2, 2));
}

@Test
public void testScanVersionForFallbackBranch() throws Exception {
FileStoreTable mainTable = createTable();
writeDataIntoTable(mainTable, 0, rowData(1, 10));
mainTable.createTag("base");

writeDataIntoTable(mainTable, 1, rowData(2, 20));
long mainSnapshotTime = mainTable.snapshotManager().snapshot(2).timeMillis();
mainTable.createBranch("bc", "base");
while (System.currentTimeMillis() <= mainSnapshotTime) {
Thread.yield();
}
FileStoreTable branchTable = mainTable.switchToBranch("bc");
writeDataIntoTable(branchTable, 2, rowData(3, 30));

FallbackReadFileStoreTable table =
new FallbackReadFileStoreTable(mainTable, branchTable, true);
FileStoreTable versioned =
table.copy(Collections.singletonMap(CoreOptions.SCAN_VERSION.key(), "2"));

assertThat(readAndCollect((FallbackReadFileStoreTable) versioned, scan -> {}))
.containsExactlyInAnyOrder(Pair.of(1, 10), Pair.of(2, 20));
}

private DataTableScan queryAuthScan(DataTableScan delegate, TableQueryAuthResult authResult) {
DataTableScan scan =
Mockito.mock(DataTableScan.class, AdditionalAnswers.delegatesTo(delegate));
Expand Down
Loading