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

   # Rationale for this change
   
   `null_value_counts` is optional in a data file. When a file has none, Java's 
`StrictMetricsEvaluator` treats every column as possibly containing nulls:
   
   ```java
   private boolean canContainNulls(Integer id) {
     return nullCounts == null || (nullCounts.containsKey(id) && 
nullCounts.get(id) > 0);
   }
   ```
   
   `_StrictMetricsEvaluationVisitor._can_contain_nulls` read the missing map as 
empty, so it treated every column as having no nulls. For an optional column 
`x` with bounds 1 to 5 and no null counts, `x < 10`, `x <= 5`, `x > 0` and `x 
>= 1` returned `ROWS_MUST_MATCH`, although rows where `x` is null do not match.
   
   `_DeleteFiles` drops a data file when the strict evaluator returns 
`ROWS_MUST_MATCH`, so for such a file `delete("x < 10")` also removed the rows 
where `x` is null.
   
   Now the visitor treats every column as possibly containing nulls when the 
file has no null value counts, as Java does. A file whose map exists but has no 
entry for a column is unchanged, which also matches Java.
   
   ## Are these changes tested?
   
   Yes. `test_strict_missing_null_counts` in 
`tests/expressions/test_evaluator.py` checks the four predicates on the same 
file with null counts `{1: 0}` (must match) and without null counts (might not 
match). It fails without the change. The rest of `tests/expressions` passes, 
apart from two `test_parser.py` cases and the Cython-decoder warning tests that 
fail the same way on `main` in my environment. `ruff` and `ruff format` are 
clean on the changed files, and `mypy` reports nothing new.
   
   ## Are there any user-facing changes?
   
   Deletes no longer drop a whole data file without null value counts when the 
predicate cannot match its null rows. Such a file is now read and rewritten, so 
only the matching rows are removed.
   


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