Fix walrus truthiness on metrics bounds and identity-partition projection#3412
Open
kevinjqliu wants to merge 4 commits into
Open
Fix walrus truthiness on metrics bounds and identity-partition projection#3412kevinjqliu wants to merge 4 commits into
kevinjqliu wants to merge 4 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Inspired by the walrus issue in #3353
Summary
Several
if x := dict.get(k):checks treated legitimate falsy values as missing:lower_bounds.get(field_id)/upper_bounds.get(field_id)returnbytes.b""is a valid serialization of an empty string and was being skipped, causing metrics-based row filtering to returnROWS_MIGHT_MATCHwhen it should have beenROWS_CANNOT_MATCH(and vice versa for strict eval).accessors[...].get(file.partition)can return0or""for anIdentityTransformpartition. The walrus dropped it, so projected partition columns were filled withnullinstead of the actual value.inspect.pylower_bound/upper_boundrendering had the sameb""issue, showingNoneinstead of""inreadable_metrics.All conditions are switched to explicit
is not Nonechecks. A small_readable_boundhelper deduplicates the inspect rendering.Changes
pyiceberg/expressions/visitors.py—_InclusiveMetricsEvaluatorand_StrictMetricsEvaluatorbound lookups (21 sites).pyiceberg/io/pyarrow.py—_get_column_projection_valuesandArrowProjectionVisitormissing-field handling.pyiceberg/table/inspect.py— extract_readable_bound, use it in both theentriesand_get_files_from_manifestrendering paths.Tests
tests/expressions/test_evaluator.py— inclusive and strict evaluators with empty-string bounds, covering lower-only, upper-only, and both-bounds branches.tests/io/test_pyarrow.py— parametrized identity-transform projection with falsy partition values (0,"",None).tests/table/test_inspect.py—_readable_boundhelper plus integration tests viatbl.inspect.entries()andtbl.inspect.files()for empty-string and null bounds.