lirui-apache opened a new issue, #15273:
URL: https://github.com/apache/iceberg/issues/15273
### Apache Iceberg version
main (development)
### Query engine
Spark
### Please describe the bug 🐞
I tried to query metadata table on a branch:
```java
public void test() throws Exception {
sql("create table foo (x int, p int) using iceberg partitioned by (p)");
sql("insert into foo values (1, 1)");
sql("alter table foo create branch br1");
sql(
"select status,snapshot_id from spark_catalog.default.foo.entries
version as of 'br1' where data_file.partition.p > 0");
}
```
It fails with exception:
```shell
Cannot find field 'data_file.partition.p' in struct: struct<1: x: optional
int, 2: p: optional int>
org.apache.iceberg.exceptions.ValidationException: Cannot find field
'data_file.partition.p' in struct: struct<1: x: optional int, 2: p: optional
int>
at org.apache.iceberg.expressions.Binder.bind(Binder.java:60)
at
org.apache.iceberg.BaseEntriesTable$ManifestContentEvaluator.<init>(BaseEntriesTable.java:110)
at
org.apache.iceberg.BaseEntriesTable.planFiles(BaseEntriesTable.java:85)
at
org.apache.iceberg.ManifestEntriesTable$EntriesTableScan.doPlanFiles(ManifestEntriesTable.java:69)
at
org.apache.iceberg.SnapshotScan.planFiles(SnapshotScan.java:161)
at
org.apache.iceberg.BatchScanAdapter.planFiles(BatchScanAdapter.java:124)
```
It seems we incorrectly pass data table schema, rather than entries table
schema, to `EntriesTableScan`, and therefore we cannot bind the filter
expression. I think we should override `useRef` to properly handle the schema,
or throw an exception indicating branch is not supported for metadata tables.
### Willingness to contribute
- [x] I can contribute a fix for this bug independently
- [x] I would be willing to contribute a fix for this bug with guidance from
the Iceberg community
- [ ] I cannot contribute a fix for this bug at this time
--
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]