maxdebayser commented on code in PR #7831:
URL: https://github.com/apache/iceberg/pull/7831#discussion_r1267115691
##########
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:
I agree that the code can be simplified like that. I just want to run a
thought by you: since we have this redundancy in type information should we
perhaps take advantage of this to check that the types match? In this way we
would be able to detect bugs that result in the data written to parquet being
of a different type than what is in the schema.
--
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]