Fix column projection predicate evaluation#2254
Closed
kevinjqliu wants to merge 5 commits intoapache:mainfrom
Closed
Fix column projection predicate evaluation#2254kevinjqliu wants to merge 5 commits intoapache:mainfrom
kevinjqliu wants to merge 5 commits intoapache:mainfrom
Conversation
Contributor
Author
|
cc @gabeiglio since you implemented #1443 :) could you also take a look? |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
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
Contributor
Author
|
this isnt right. we should evaluate the column projection predicates |
Contributor
Author
|
Closing in favor of #2029 |
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.
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?