Fokko commented on code in PR #4727:
URL: https://github.com/apache/iceberg/pull/4727#discussion_r867736811
##########
python/src/iceberg/transforms.py:
##########
@@ -249,6 +249,32 @@ def result_type(self, source: IcebergType) -> IcebergType:
return StringType()
+class VoidTransform(Transform):
+ """A transform that always returns None"""
+
+ _instance = None
+
+ def __new__(cls):
+ if cls._instance is None:
+ cls._instance = super(VoidTransform, cls).__new__(cls)
+ return cls._instance
+
+ def __init__(self):
+ super().__init__("void", "transforms.always_null()")
+
+ def apply(self, value):
Review Comment:
Related to https://github.com/apache/iceberg/pull/4728/
```suggestion
def apply(self, value: Optional[S]) -> Optional[int]:
```
##########
python/src/iceberg/transforms.py:
##########
@@ -249,6 +249,32 @@ def result_type(self, source: IcebergType) -> IcebergType:
return StringType()
+class VoidTransform(Transform):
+ """A transform that always returns None"""
+
+ _instance = None
+
+ def __new__(cls):
Review Comment:
We could add a test for this:
```python
def test_check_if_identical():
assert transforms.always_null() is transforms.always_null()
```
##########
python/src/iceberg/transforms.py:
##########
@@ -249,6 +249,32 @@ def result_type(self, source: IcebergType) -> IcebergType:
return StringType()
+class VoidTransform(Transform):
+ """A transform that always returns None"""
+
+ _instance = None
+
+ def __new__(cls):
+ if cls._instance is None:
+ cls._instance = super(VoidTransform, cls).__new__(cls)
+ return cls._instance
+
+ def __init__(self):
+ super().__init__("void", "transforms.always_null()")
+
+ def apply(self, value):
+ return None
+
+ def can_transform(self, target: IcebergType) -> bool:
+ return True
+
+ def result_type(self, source: IcebergType) -> IcebergType:
+ return source
+
+ def to_human_string(self, value) -> str:
Review Comment:
```suggestion
def to_human_string(self, Optional[value]) -> str:
```
--
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]