You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by GitBox <gi...@apache.org> on 2022/05/09 08:05:28 UTC

[GitHub] [iceberg] Fokko commented on a diff in pull request #4727: add VoidTransform

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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org