Skip to content

Commit a093d4a

Browse files
committed
Fix truncate transform ordering comparison
1 parent 48e710d commit a093d4a

2 files changed

Lines changed: 6 additions & 10 deletions

File tree

pyiceberg/transforms.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -895,16 +895,7 @@ def truncate_func(v: Any) -> Any:
895895
return lambda v: truncate_func(v) if v is not None else None
896896

897897
def satisfies_order_of(self, other: Transform[S, T]) -> bool:
898-
if self == other:
899-
return True
900-
elif (
901-
isinstance(self.source_type, StringType)
902-
and isinstance(other, TruncateTransform)
903-
and isinstance(other.source_type, StringType)
904-
):
905-
return self.width >= other.width
906-
907-
return False
898+
return isinstance(other, TruncateTransform) and self.width >= other.width
908899

909900
def to_human_string(self, _: IcebergType, value: S | None) -> str:
910901
if value is None:

tests/test_transforms.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,11 @@ def test_truncate_method(type_var: PrimitiveType, value: Any, expected_human_str
512512
assert truncate_transform.satisfies_order_of(truncate_transform)
513513

514514

515+
def test_truncate_satisfies_order_of() -> None:
516+
assert TruncateTransform(5).satisfies_order_of(TruncateTransform(3))
517+
assert not TruncateTransform(3).satisfies_order_of(TruncateTransform(5))
518+
519+
515520
def test_unknown_transform() -> None:
516521
unknown_transform = UnknownTransform("unknown") # type: ignore
517522
assert str(unknown_transform) == str(eval(repr(unknown_transform)))

0 commit comments

Comments
 (0)