kdn36 commented on PR #4359:
URL: https://github.com/apache/iceberg-python/pull/4359#issuecomment-7041713438
(With AI) Another case this PR should fix, found with AI and reproduced on
0.12.0: field IDs swapped relative to the names, as after renames. The full
scan reads by field ID, while the bounds are stored by name, so the filter
prunes the file.
```python
import tempfile
import pyarrow as pa
import pyarrow.parquet as pq
from pyiceberg.catalog.sql import SqlCatalog
from pyiceberg.schema import Schema
from pyiceberg.types import LongType, NestedField
d = tempfile.mkdtemp()
cat = SqlCatalog("c", uri="sqlite:///:memory:", warehouse=f"file://{d}")
cat.create_namespace("ns")
t = cat.create_table(
"ns.t", schema=Schema(NestedField(1, "a", LongType()), NestedField(2,
"b", LongType()))
)
# column `a` carries field id 2 and `b` field id 1, the reverse of the table
schema = pa.schema([
pa.field("a", pa.int64(), metadata={b"PARQUET:field_id": b"2"}),
pa.field("b", pa.int64(), metadata={b"PARQUET:field_id": b"1"}),
])
pq.write_table(pa.table({"a": [1], "b": [2]}, schema=schema),
f"{d}/a.parquet")
t.add_files([f"{d}/a.parquet"])
t = cat.load_table("ns.t")
print(t.scan().to_arrow().to_pylist())
# [{'a': 2, 'b': 1}]
print(t.scan(row_filter="a = 2").to_arrow().to_pylist())
# [], should be [{'a': 2, 'b': 1}]
```
--
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]