Fokko commented on code in PR #7831:
URL: https://github.com/apache/iceberg/pull/7831#discussion_r1267853906


##########
python/pyiceberg/io/pyarrow.py:
##########
@@ -1013,3 +1025,271 @@ def map_key_partner(self, partner_map: 
Optional[pa.Array]) -> Optional[pa.Array]
 
     def map_value_partner(self, partner_map: Optional[pa.Array]) -> 
Optional[pa.Array]:
         return partner_map.items if isinstance(partner_map, pa.MapArray) else 
None
+
+
+class StatsAggregator:
+    def __init__(self, type_string: str, trunc_length: Optional[int] = None) 
-> None:
+        self.current_min: Any = None
+        self.current_max: Any = None
+        self.trunc_length = trunc_length
+        self.primitive_type: Optional[PrimitiveType] = None
+
+        if type_string == "BOOLEAN":
+            self.primitive_type = BooleanType()
+        elif type_string == "INT32":
+            self.primitive_type = IntegerType()
+        elif type_string == "INT64":
+            self.primitive_type = LongType()
+        elif type_string == "INT96":
+            raise NotImplementedError("Statistics not implemented for INT96 
physical type")
+        elif type_string == "FLOAT":
+            self.primitive_type = FloatType()
+        elif type_string == "DOUBLE":
+            self.primitive_type = DoubleType()
+        elif type_string == "BYTE_ARRAY":
+            self.primitive_type = BinaryType()
+        elif type_string == "FIXED_LEN_BYTE_ARRAY":
+            self.primitive_type = BinaryType()
+        else:
+            raise AssertionError(f"Unknown physical type {type_string}")

Review Comment:
   Yes, I think we can do this. I would suggest creating a visitor that will 
convert an Iceberg type to an Arrow string type. We have to make sure that we 
test for all the primitive types.



-- 
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]

Reply via email to