wooyeong commented on code in PR #9455: URL: https://github.com/apache/iceberg/pull/9455#discussion_r1475687874
########## spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/source/SparkTable.java: ########## @@ -131,12 +133,12 @@ public SparkTable(Table icebergTable, boolean refreshEagerly) { public SparkTable(Table icebergTable, String branch, boolean refreshEagerly) { this(icebergTable, refreshEagerly); this.branch = branch; + final Snapshot snapshot = icebergTable.snapshot(branch); ValidationException.check( - branch == null - || SnapshotRef.MAIN_BRANCH.equals(branch) - || icebergTable.snapshot(branch) != null, + branch == null || SnapshotRef.MAIN_BRANCH.equals(branch) || snapshot != null, "Cannot use branch (does not exist): %s", branch); + this.snapshotId = snapshot.snapshotId(); Review Comment: >Won't this throw an NPE in some cases as snapshot could be null? We have a vaildator just above, a `ValidationException` will be thrown if so. > Also, I am not sure this logic is correct. I somewhat agree with you. While a given snapshot ID is constant, a given branch may change its state. My first proposal was to check `name`, `branch`, and `snapshotId` together, and as we cannot set both `branch` and `snapshotId`, we can have only one choice, thus this may be a reasonable approach. -- 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: issues-unsubscr...@iceberg.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For additional commands, e-mail: issues-h...@iceberg.apache.org