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
11 changes: 1 addition & 10 deletions pyiceberg/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -895,16 +895,7 @@ def truncate_func(v: Any) -> Any:
return lambda v: truncate_func(v) if v is not None else None

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)
):
return self.width >= other.width

return False
return isinstance(other, TruncateTransform) and self.width >= other.width

def to_human_string(self, _: IcebergType, value: S | None) -> str:
if value is None:
Expand Down
5 changes: 5 additions & 0 deletions tests/test_transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,11 @@ 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() -> None:
assert TruncateTransform(5).satisfies_order_of(TruncateTransform(3))
assert not TruncateTransform(3).satisfies_order_of(TruncateTransform(5))


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