Skip to content

Fix TruncateTransform.satisfies_order_of crashing on different widths#3682

Open
SAY-5 wants to merge 1 commit into
apache:mainfrom
SAY-5:fix-truncate-satisfies-order-of
Open

Fix TruncateTransform.satisfies_order_of crashing on different widths#3682
SAY-5 wants to merge 1 commit into
apache:mainfrom
SAY-5:fix-truncate-satisfies-order-of

Conversation

@SAY-5

@SAY-5 SAY-5 commented Jul 18, 2026

Copy link
Copy Markdown

Closes #3680

Rationale for this change

TruncateTransform.satisfies_order_of reads self.source_type (and other.source_type) when the two transforms are not equal, but TruncateTransform.__init__ only sets _width and never sets _source_type. Comparing two truncate transforms of different widths therefore raises AttributeError: 'TruncateTransform' object has no attribute '_source_type' instead of returning a boolean, because same-width comparisons only work by taking the early self == other return. Two truncate transforms are ordered by width, so the comparison can be decided from the widths alone.

Are these changes tested?

Yes. Added test_truncate_satisfies_order_of_different_widths and confirmed the existing transform tests still pass (pytest tests/test_transforms.py -k "truncate or satisfies_order"). The two test_truncate_pyarrow_transforms cases that fail locally require the optional pyiceberg-core extra and are unrelated to this change.

Are there any user-facing changes?

No.

Signed-off-by: Sai Asish Y <say.apm35@gmail.com>
Comment thread pyiceberg/transforms.py
and isinstance(other, TruncateTransform)
and isinstance(other.source_type, StringType)
):
elif isinstance(other, TruncateTransform):

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

dropping the source_type check means an int/long/decimal transform now satisfies_order_of another purely on width. is that the intended widening, or should it stay type-gated? the java implementation only returns true within the same type family, so one type family claiming to satisfy another (string vs int) could let an invalid sort-order replacement through.

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