Fix TruncateTransform.satisfies_order_of for different widths (#3680) - #3854
Open
hedger9487 wants to merge 1 commit into
Open
Fix TruncateTransform.satisfies_order_of for different widths (#3680)#3854hedger9487 wants to merge 1 commit into
hedger9487 wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a runtime AttributeError in TruncateTransform.satisfies_order_of when comparing truncate transforms with different widths by removing reliance on the unset source_type, aligning behavior with the Iceberg reference implementation.
Changes:
- Simplified
TruncateTransform.satisfies_order_ofto checkisinstance(other, TruncateTransform)and compare widths (self.width >= other.width). - Added unit tests covering width comparisons and ensuring non-truncate transforms return
False.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
pyiceberg/transforms.py |
Fixes satisfies_order_of to avoid accessing an uninitialized private attribute and bases ordering satisfaction on width comparison. |
tests/test_transforms.py |
Adds regression tests for truncate-width comparisons and cross-transform comparisons. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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.
Closes #3680
Rationale for this change
TruncateTransform.satisfies_order_ofpreviously accessedself.source_type(andother.source_type), which raisedAttributeError: 'TruncateTransform' object has no attribute '_source_type'whenever comparing truncate transforms with different widths.Per the Iceberg spec and matching the Java reference implementation, ordering satisfaction between two truncate transforms depends purely on the width comparison (
self.width >= other.width).This PR:
TruncateTransform.satisfies_order_ofto checkisinstance(other, TruncateTransform)and compareself.width >= other.width.Are these changes tested?
Yes, added
test_truncate_satisfies_order_ofintests/test_transforms.py. All tests and pre-commit linters pass cleanly.Are there any user-facing changes?
No.