Skip to content

Commit db445e1

Browse files
authored
fix: correct UUIDType partition representation for BucketTransform
1 parent 996a7ba commit db445e1

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

pyiceberg/partitioning.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -467,8 +467,15 @@ def _(type: IcebergType, value: Optional[time]) -> Optional[int]:
467467

468468

469469
@_to_partition_representation.register(UUIDType)
470-
def _(type: IcebergType, value: Optional[uuid.UUID]) -> Optional[str]:
471-
return str(value) if value is not None else None
470+
def _(type: IcebergType, value: Optional[Union[uuid.UUID,int]]) -> Optional[str|int]:
471+
if value is None:
472+
return None
473+
if isinstance(value, uuid.UUID):
474+
return str(value) # IdentityTransform
475+
elif isinstance(value, int):
476+
return value # BucketTransform
477+
else:
478+
return value
472479

473480

474481
@_to_partition_representation.register(PrimitiveType)

0 commit comments

Comments
 (0)