Skip to content

Commit 2990256

Browse files
committed
Reject unsupported identity transform types
1 parent f66d1b3 commit 2990256

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

pyiceberg/transforms.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@
7373
DateType,
7474
DecimalType,
7575
FixedType,
76+
GeographyType,
77+
GeometryType,
7678
IcebergType,
7779
IntegerType,
7880
LongType,
@@ -717,7 +719,7 @@ def transform(self, source: IcebergType) -> Callable[[S | None], S | None]:
717719
return lambda v: v
718720

719721
def can_transform(self, source: IcebergType) -> bool:
720-
return source.is_primitive
722+
return source.is_primitive and not isinstance(source, (GeographyType, GeometryType))
721723

722724
def result_type(self, source: IcebergType) -> IcebergType:
723725
return source

tests/test_transforms.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@
101101
DoubleType,
102102
FixedType,
103103
FloatType,
104+
GeographyType,
105+
GeometryType,
104106
IntegerType,
105107
LongType,
106108
NestedField,
@@ -255,6 +257,11 @@ def test_identity_transform_unknown_type() -> None:
255257
assert IdentityTransform().to_human_string(UnknownType(), None) == "null"
256258

257259

260+
@pytest.mark.parametrize("type_var", [GeometryType(), GeographyType()])
261+
def test_identity_transform_unsupported_type(type_var: PrimitiveType) -> None:
262+
assert not IdentityTransform().can_transform(type_var)
263+
264+
258265
def test_string_with_surrogate_pair() -> None:
259266
string_with_surrogate_pair = "string with a surrogate pair: 💰"
260267
as_bytes = bytes(string_with_surrogate_pair, UTF8)

0 commit comments

Comments
 (0)