pvary commented on code in PR #7362:
URL: https://github.com/apache/iceberg/pull/7362#discussion_r1189839301
##########
flink/v1.17/flink/src/main/java/org/apache/iceberg/flink/source/ScanContext.java:
##########
@@ -149,12 +152,26 @@ private void validate() {
}
Preconditions.checkArgument(
- !(startTag != null && startSnapshotId() != null),
- "START_SNAPSHOT_ID and START_TAG cannot both be set.");
+ atMostOneNonNull(startSnapshotId(), startTag,
startSnapshotTimestamp()),
+ "Cannot specify more than one of start-snapshot-id, start-tag, or
start-snapshot-timestamp.");
Preconditions.checkArgument(
- !(endTag != null && endSnapshotId() != null),
- "END_SNAPSHOT_ID and END_TAG cannot both be set.");
+ atMostOneNonNull(endSnapshotId(), endTag, endSnapshotTimestamp()),
+ "Cannot specify more than one of end-snapshot-id, end-tag, or
end-snapshot-timestamp.");
+ }
+
+ private static boolean atMostOneNonNull(Object... objects) {
Review Comment:
Seems a bit too many lines of code for:
```
return Arrays.stream(objects).filter(Objects::nonNull).count() < 2;
```
But if we do not want to use streams, for readability I would remove the
early return - only used in failure case when performance is not really
important.
We can do a full count
--
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]