Fokko commented on code in PR #43: URL: https://github.com/apache/iceberg-python/pull/43#discussion_r1349235131
########## pyiceberg/io/pyarrow.py: ########## @@ -1099,21 +1099,70 @@ def map_value_partner(self, partner_map: Optional[pa.Array]) -> Optional[pa.Arra return partner_map.items if isinstance(partner_map, pa.MapArray) else None -_PRIMITIVE_TO_PHYSICAL = { - BooleanType(): "BOOLEAN", - IntegerType(): "INT32", - LongType(): "INT64", - FloatType(): "FLOAT", - DoubleType(): "DOUBLE", - DateType(): "INT32", - TimeType(): "INT64", - TimestampType(): "INT64", - TimestamptzType(): "INT64", - StringType(): "BYTE_ARRAY", - UUIDType(): "FIXED_LEN_BYTE_ARRAY", - BinaryType(): "BYTE_ARRAY", -} -_PHYSICAL_TYPES = set(_PRIMITIVE_TO_PHYSICAL.values()).union({"INT96"}) +def _primitive_to_phyisical(iceberg_type: PrimitiveType) -> str: + return visit(iceberg_type, _PRIMITIVE_TO_PHYISCAL_TYPE_VISITOR) + + +class PrimitiveToPyhsicalType(SchemaVisitorPerPrimitiveType[str]): + def schema(self, schema: Schema, struct_result: str) -> str: + raise ValueError(f"Expected primitive-type, got: {schema}") + + def struct(self, struct: StructType, field_results: List[str]) -> str: + raise ValueError(f"Expected primitive-type, got: {struct}") + + def field(self, field: NestedField, field_result: str) -> str: + raise ValueError(f"Expected primitive-type, got: {field}") + + def list(self, list_type: ListType, element_result: str) -> str: + raise ValueError(f"Expected primitive-type, got: {list_type}") + + def map(self, map_type: MapType, key_result: str, value_result: str) -> str: + raise ValueError(f"Expected primitive-type, got: {map_type}") + + def visit_fixed(self, fixed_type: FixedType) -> str: + return "BYTE_ARRAY" + + def visit_decimal(self, decimal_type: DecimalType) -> str: + raise ValueError("unknown") Review Comment: I would say `FIXED_LEN_BYTE_ARRAY`. This visitor is just to double-check that we get the type that we expect. -- 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-unsubscr...@iceberg.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For additional commands, e-mail: issues-h...@iceberg.apache.org