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
2 changes: 1 addition & 1 deletion pyiceberg/partitioning.py
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ def _to_partition_representation(type: IcebergType, value: Any) -> Any:
can return date that still needs to be transformed into an int (days
since epoch).
"""
return TypeError(f"Unsupported partition field type: {type}")
raise TypeError(f"Unsupported partition field type: {type}")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

No other same mistake as far as I checked.



@_to_partition_representation.register(TimestampType)
Expand Down
14 changes: 13 additions & 1 deletion tests/table/test_partitioning.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@
import pytest

from pyiceberg.exceptions import ValidationError
from pyiceberg.partitioning import UNPARTITIONED_PARTITION_SPEC, PartitionField, PartitionSpec
from pyiceberg.partitioning import (
UNPARTITIONED_PARTITION_SPEC,
PartitionField,
PartitionSpec,
_to_partition_representation,
)
from pyiceberg.schema import Schema
from pyiceberg.transforms import (
BucketTransform,
Expand Down Expand Up @@ -253,6 +258,13 @@ def test_transform_consistency_with_pyarrow_transform(source_type: PrimitiveType
assert t.transform(source_type)(value) == t.pyarrow_transform(source_type)(pa.array([value])).to_pylist()[0]


def test_to_partition_representation_unsupported_type() -> None:
unsupported_type = StructType(NestedField(1, "x", StringType()))

with pytest.raises(TypeError, match="Unsupported partition field type: struct"):
_to_partition_representation(unsupported_type, "value")


def test_deserialize_partition_field_v2() -> None:
json_partition_spec = """{"source-id": 1, "field-id": 1000, "transform": "truncate[19]", "name": "str_truncate"}"""

Expand Down