Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions pyiceberg/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -897,11 +897,7 @@ def truncate_func(v: Any) -> Any:
def satisfies_order_of(self, other: Transform[S, T]) -> bool:
if self == other:
return True
elif (
isinstance(self.source_type, StringType)
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.

return self.width >= other.width

return False
Expand Down
6 changes: 6 additions & 0 deletions tests/test_transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,12 @@ def test_truncate_method(type_var: PrimitiveType, value: Any, expected_human_str
assert truncate_transform.satisfies_order_of(truncate_transform)


def test_truncate_satisfies_order_of_different_widths() -> None:
assert TruncateTransform(5).satisfies_order_of(TruncateTransform(3))
assert not TruncateTransform(3).satisfies_order_of(TruncateTransform(5))
assert not TruncateTransform(5).satisfies_order_of(BucketTransform(3))


def test_unknown_transform() -> None:
unknown_transform = UnknownTransform("unknown") # type: ignore
assert str(unknown_transform) == str(eval(repr(unknown_transform)))
Expand Down
Loading