anishmehta24 opened a new pull request, #4090:
URL: https://github.com/apache/iceberg-python/pull/4090

   # Rationale for this change
   
   `_StrictMetricsEvaluator` raises when a predicate references a nested 
column, so `delete()` and `overwrite()` with such a filter fail during planning:
   
   ```python
   schema = pa.schema([pa.field("id", pa.int64()), pa.field("s", 
pa.struct([pa.field("x", pa.int64())]))])
   tbl = catalog.create_table("default.t", schema=schema)
   tbl.append(pa.table({"id": [1, 2], "s": [{"x": 1}, {"x": 5}]}, 
schema=schema))
   tbl.delete("s.x != 5")
   # ValueError: Cannot find field, might be nested or missing: 3
   ```
   
   `NotEqualTo`, `In` and `NotIn` look up the field in the top-level struct 
before checking bounds, so they fail even on files that pyiceberg writes 
itself, which have no nested bounds. The range and equality predicates fail 
once the file has bounds for the nested column, for example files written by 
Spark. Java fixed this in apache/iceberg#11261: for a nested column, strict 
evaluation returns `ROWS_MIGHT_NOT_MATCH` because nested null counts are not 
reliable. This change does the same. It also matters for #3810, which starts 
writing nested bounds from pyiceberg. After it, the delete above rewrites the 
file and leaves `[{'id': 2, 's': {'x': 5}}]`.
   
   ## Are these changes tested?
   
   Yes. `test_strict_nested_column` in `tests/expressions/test_evaluator.py` 
covers nested columns with and without bounds, and it fails on main with the 
`ValueError` above. The evaluator, visitor and residual tests pass.
   
   ## Are there any user-facing changes?
   
   Yes. `delete()` and `overwrite()` with a filter on a nested struct field no 
longer raise.
   
   Written with help from Claude.
   


-- 
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]

Reply via email to