Skip to content

Fix TruncateTransform.satisfies_order_of for different widths (#3680) - #3854

Open
hedger9487 wants to merge 1 commit into
apache:mainfrom
hedger9487:fix/truncate-satisfies-order-of-3680
Open

Fix TruncateTransform.satisfies_order_of for different widths (#3680)#3854
hedger9487 wants to merge 1 commit into
apache:mainfrom
hedger9487:fix/truncate-satisfies-order-of-3680

Conversation

@hedger9487

Copy link
Copy Markdown

Closes #3680

Rationale for this change

TruncateTransform.satisfies_order_of previously accessed self.source_type (and other.source_type), which raised AttributeError: '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:

  1. Updates TruncateTransform.satisfies_order_of to check isinstance(other, TruncateTransform) and compare self.width >= other.width.
  2. Adds unit tests covering same/different width comparisons and cross-transform comparisons.

Are these changes tested?

Yes, added test_truncate_satisfies_order_of in tests/test_transforms.py. All tests and pre-commit linters pass cleanly.

Are there any user-facing changes?

No.

Copilot AI lite review requested due to automatic review settings August 26, 2026 01:38

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_of to check isinstance(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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TruncateTransform.satisfies_order_of raises AttributeError for different widths

2 participants