Fokko commented on code in PR #8267:
URL: https://github.com/apache/iceberg/pull/8267#discussion_r1288262545
##########
python/pyiceberg/conversions.py:
##########
@@ -228,7 +228,9 @@ def _(_: StringType, value: str) -> bytes:
@to_bytes.register(UUIDType)
-def _(_: UUIDType, value: uuid.UUID) -> bytes:
+def _(_: UUIDType, value: Union[uuid.UUID, bytes]) -> bytes:
+ if isinstance(value, bytes):
+ return value
return _UUID_STRUCT.pack((value.int >> 64) & 0xFFFFFFFFFFFFFFFF, value.int
& 0xFFFFFFFFFFFFFFFF)
Review Comment:
Slightly related, I think we can do:
```suggestion
return value.bytes
```
```
>>> import uuid
>>> from struct import Struct
>>> _UUID_STRUCT = Struct(">QQ")
>>> u = uuid.uuid4()
>>> u
UUID('43c6697a-4d50-44ee-806e-edf58b08430e')
>>> u.bytes
b'C\xc6izMPD\xee\x80n\xed\xf5\x8b\x08C\x0e'
>>> _UUID_STRUCT.pack((u.int >> 64) & 0xFFFFFFFFFFFFFFFF, u.int &
0xFFFFFFFFFFFFFFFF)
b'C\xc6izMPD\xee\x80n\xed\xf5\x8b\x08C\x0e'
```
##########
python/dev/Dockerfile:
##########
@@ -65,6 +65,8 @@ RUN chmod u+x /opt/spark/sbin/* && \
RUN pip3 install -q ipython
+RUN pip3 install 'pyiceberg[pyarrow,duckdb,pandas]==0.4.0'
Review Comment:
This should not be required?
##########
python/pyiceberg/expressions/literals.py:
##########
@@ -139,7 +139,7 @@ def literal(value: L) -> Literal[L]:
elif isinstance(value, str):
return StringLiteral(value)
elif isinstance(value, UUID):
- return UUIDLiteral(value)
+ return UUIDLiteral(value) # type: ignore
Review Comment:
```suggestion
return UUIDLiteral(value.bytes)
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]