nastra commented on code in PR #7621:
URL: https://github.com/apache/iceberg/pull/7621#discussion_r1195154004
##########
core/src/main/java/org/apache/iceberg/util/SnapshotUtil.java:
##########
@@ -144,12 +144,25 @@ public static Snapshot oldestAncestorOf(long snapshotId,
Function<Long, Snapshot
return lastSnapshot;
}
+ /**
+ * Returns the ancestors of the given snapshot id or throws an exception if
the given snapshot id
+ * cannot be found.
+ */
public static Iterable<Snapshot> ancestorsOf(long snapshotId, Function<Long,
Snapshot> lookup) {
Snapshot start = lookup.apply(snapshotId);
Preconditions.checkArgument(start != null, "Cannot find snapshot: %s",
snapshotId);
return ancestorsOf(start, lookup);
}
+ /**
+ * Returns the ancestors of the given snapshot id. If there are no ancestors
or the given snapshot
+ * id cannot be found, an empty iterable is returned.
+ */
+ public static Iterable<Snapshot> maybeAncestorsOf(
Review Comment:
this method only exists so that we have consistent error reporting in
https://github.com/apache/iceberg/blob/1521296dd253c829dedc3e83ffda4cd2622667e2/core/src/test/java/org/apache/iceberg/TestSnapshotLoading.java#L169
for V1 and V2 tables (because we want to skip
`Preconditions.checkArgument(start != null, "Cannot find snapshot: %s",
snapshotId)`).
Alternatively we could have a `ancestorsOf()` with a boolean flag to skip
the `snapshotId` validation.
--
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]