-
Notifications
You must be signed in to change notification settings - Fork 393
Fix column projection predicate evaluation #2254
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix column projection predicate evaluation #2254
Conversation
|
cc @gabeiglio since you implemented #1443 :) could you also take a look? |
Co-authored-by: Copilot <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes a bug in predicate evaluation for column projection where predicates on columns not present in the Parquet file schema would incorrectly return no results. The fix changes the behavior to return AlwaysTrue when a field has no initial_default, allowing for proper row-level filtering.
Key changes:
- Modified
_ColumnNameTranslatorto returnAlwaysTrueinstead ofAlwaysFalsefor missing fields withoutinitial_default - Added comprehensive unit tests for the
translate_column_namesfunction - Added integration tests for partition value projection with predicates
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| pyiceberg/expressions/visitors.py | Updated _ColumnNameTranslator to handle missing fields without initial_default by returning AlwaysTrue |
| tests/expressions/test_visitors.py | Added comprehensive unit tests for translate_column_names function covering various scenarios |
| tests/io/test_pyarrow.py | Added integration tests for partition value projection with predicates |
Comments suppressed due to low confidence (1)
tests/expressions/test_visitors.py:1684
- The test creates a field with
initial_default="default"but never tests the behavior when this field is missing from the file schema. Consider adding a test case to verify that fields with string defaults are handled correctly.
NestedField(field_id=1, name="existing_col", field_type=StringType(), required=False, initial_default="default"),
06c4a4d to
50b7b39
Compare
|
this isnt right. we should evaluate the column projection predicates |
|
Closing in favor of #2029 |
Rationale for this change
Closes #2028
Heavily inspired by #2029 (thanks @Erigara)
This PR fixes a bug where predicate evaluation for a column that is not in the parquet file schema will return no result. This is due to
_ColumnNameTranslatorvisitor returningAlwaysFalsewhen the column cannot be found in the file schema.This PR follows the change in #1644 to evaluate predicates based on a field's
initial_default. When the evaluated field does not haveinitial_default,_ColumnNameTranslatorwill now returnAlwaysTrueto scan the entire parquet file and pass the result along for further evaluation.Are these changes tested?
Yes, added some unit tests for
_ColumnNameTranslator/translate_column_namesAdded a test for predicate evaluation for projected columns.
Are there any user-facing changes?