Content-Length: 332854 | pFad | http://github.com/apache/iceberg/commit/c3d315ea56c03c4f10d8cc0b7a5e59450347ac2b

D0 useBranch · apache/iceberg@c3d315e · GitHub
Skip to content

Commit

Permalink
useBranch
Browse files Browse the repository at this point in the history
  • Loading branch information
hililiwei committed Nov 2, 2022
1 parent 6c8e1c4 commit c3d315e
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 2 deletions.
16 changes: 15 additions & 1 deletion .palantir/revapi.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
versionOverrides:
org.apache.iceberg:iceberg-api:apache-iceberg-0.14.0: "0.14.0"
org.apache.iceberg:iceberg-api:apache-iceberg-1.1.0: "1.1.0"
acceptedBreaks:
apache-iceberg-1.1.0:
org.apache.iceberg:iceberg-api:
- code: "java.method.addedToInterface"
new: "method ThisT org.apache.iceberg.IncrementalScan<ThisT, T extends org.apache.iceberg.ScanTask, G extends org.apache.iceberg.ScanTaskGroup<T extends org.apache.iceberg.ScanTask>>::useBranch(java.lang.String)"
justification: "new API method for Ref"
- code: "java.method.addedToInterface"
new: "method ThisT org.apache.iceberg.IncrementalScan<ThisT, T extends org.apache.iceberg.ScanTask, G extends org.apache.iceberg.ScanTaskGroup<T extends org.apache.iceberg.ScanTask>>::toSnapshot(java.lang.String)"
justification: "new API method for Ref"
- code: "java.method.addedToInterface"
new: "method ThisT org.apache.iceberg.IncrementalScan<ThisT, T extends org.apache.iceberg.ScanTask, G extends org.apache.iceberg.ScanTaskGroup<T extends org.apache.iceberg.ScanTask>>::fromSnapshotInclusive(java.lang.String)"
justification: "new API method for Ref"
- code: "java.method.addedToInterface"
new: "method ThisT org.apache.iceberg.IncrementalScan<ThisT, T extends org.apache.iceberg.ScanTask, G extends org.apache.iceberg.ScanTaskGroup<T extends org.apache.iceberg.ScanTask>>::fromSnapshotExclusive(java.lang.String)"
justification: "new API method for Ref"
apache-iceberg-0.14.0:
org.apache.iceberg:iceberg-api:
- code: "java.class.defaultSerializationChanged"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ protected abstract CloseableIterable<T> doPlanFiles(
public ThisT fromSnapshotInclusive(String fromSnapshotRef) {
SnapshotRef snapshotRef = table().refs().get(fromSnapshotRef);
Preconditions.checkArgument(snapshotRef != null, "Cannot find ref %s", fromSnapshotRef);
Preconditions.checkArgument(snapshotRef.isTag(), "Ref %s is not a tag", fromSnapshotRef);

TableScanContext newContext = context().fromSnapshotIdInclusive(snapshotRef.snapshotId());

Expand All @@ -61,6 +62,7 @@ public ThisT fromSnapshotExclusive(String fromSnapshotRef) {
// as fromSnapshotId could be matched to a parent snapshot that is already expired
SnapshotRef snapshotRef = table().refs().get(fromSnapshotRef);
Preconditions.checkArgument(snapshotRef != null, "Cannot find ref %s", fromSnapshotRef);
Preconditions.checkArgument(snapshotRef.isTag(), "Ref %s is not a tag", fromSnapshotRef);

TableScanContext newContext = context().fromSnapshotIdExclusive(snapshotRef.snapshotId());

Expand Down Expand Up @@ -88,6 +90,8 @@ public ThisT toSnapshot(String toSnapshotRef) {
SnapshotRef snapshotRef = table().refs().get(toSnapshotRef);
Preconditions.checkArgument(
snapshotRef != null, "Cannot find the snapshot ref: %s", toSnapshotRef);
Preconditions.checkArgument(snapshotRef.isTag(), "Ref %s is not a tag", toSnapshotRef);

TableScanContext newContext = context().toSnapshotId(snapshotRef.snapshotId());
return newRefinedScan(tableOps(), table(), schema(), newContext);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,12 @@ public void testFromSnapshotInclusiveWithBranch() {
IllegalArgumentException.class,
String.format("Ref %s is not a branch", tagName),
() -> newScan().fromSnapshotInclusive(snapshotCId).useBranch(tagName));

AssertHelpers.assertThrows(
"Should throw exception",
IllegalArgumentException.class,
String.format("Ref %s is not a tag", branchName),
() -> newScan().fromSnapshotInclusive(branchName));
}

@Test
Expand All @@ -112,7 +118,7 @@ public void testFromSnapshotExclusive() {
}

@Test
public void testFromSnapshotExclusiveWithBranch() {
public void testFromSnapshotExclusiveWithRef() {
table.newFastAppend().appendFile(FILE_A).commit();
long snapshotAId = table.currentSnapshot().snapshotId();

Expand Down Expand Up @@ -150,6 +156,12 @@ public void testFromSnapshotExclusiveWithBranch() {
IllegalArgumentException.class,
String.format("Ref %s is not a branch", tagName),
() -> newScan().fromSnapshotExclusive(snapshotCId).useBranch(tagName));

AssertHelpers.assertThrows(
"Should throw exception",
IllegalArgumentException.class,
String.format("Ref %s is not a tag", branchName),
() -> newScan().fromSnapshotExclusive(branchName));
}

@Test
Expand Down Expand Up @@ -178,11 +190,16 @@ public void testToSnapshot() {
long snapshotAId = table.currentSnapshot().snapshotId();
table.newFastAppend().appendFile(FILE_B).commit();
long snapshotBId = table.currentSnapshot().snapshotId();
String tagName = "t2";
table.manageSnapshots().createTag(tagName, snapshotBId).commit();
table.newFastAppend().appendFile(FILE_C).commit();
long snapshotCId = table.currentSnapshot().snapshotId();

IncrementalAppendScan scan = newScan().toSnapshot(snapshotBId);
Assert.assertEquals(2, Iterables.size(scan.planFiles()));

IncrementalAppendScan scan2 = newScan().toSnapshot(tagName);
Assert.assertEquals(2, Iterables.size(scan2.planFiles()));
}

@Test
Expand Down

0 comments on commit c3d315e

Please sign in to comment.








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/apache/iceberg/commit/c3d315ea56c03c4f10d8cc0b7a5e59450347ac2b

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy