chenjian2664 commented on code in PR #17735:
URL: https://github.com/apache/iceberg/pull/17735#discussion_r4717273983
##########
core/src/main/java/org/apache/iceberg/SnapshotScan.java:
##########
@@ -83,10 +83,12 @@ protected ScanMetrics scanMetrics() {
protected Map<Integer, PartitionSpec> specs() {
Map<Integer, PartitionSpec> specs = table().specs();
// requires latest schema
- if (!useSnapshotSchema()
- || snapshotId() == null
- || table().currentSnapshot() == null
- || snapshotId().equals(table().currentSnapshot().snapshotId())) {
+ if (!useSnapshotSchema() || snapshotId() == null) {
+ return specs;
+ }
+
+ Snapshot currentSnapshot = table().currentSnapshot();
+ if (currentSnapshot != null &&
snapshotId().equals(currentSnapshot.snapshotId())) {
return specs;
}
Review Comment:
Please call out this trade-off in the PR and pin it with a test. On an
empty-main table, filtering a branch snapshot on a column added after that
snapshot used to plan, but now throws `Cannot find field`, because specs are
rebound to the older snapshot schema. Spark reaches this path: branch reads
keep the current schema but pin with `useSnapshot(branchHead)`, so a WAP audit
filter on a new column fails on unpublished tables. With a main snapshot
present it already failed, so this aligns the two cases rather than adding a
new failure mode.
##########
core/src/main/java/org/apache/iceberg/SnapshotScan.java:
##########
@@ -83,10 +83,12 @@ protected ScanMetrics scanMetrics() {
protected Map<Integer, PartitionSpec> specs() {
Map<Integer, PartitionSpec> specs = table().specs();
// requires latest schema
Review Comment:
Nit
```suggestion
// latest-schema specs apply unless scanning a non-current snapshot with
its own schema
```
--
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]