Skip to content

Commit a6969b1

Browse files
committed
test: enumerate PyArrow primitive type mappings
Generated-by: OpenAI Codex (GPT-6)
1 parent 1d4f8d3 commit a6969b1

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

‎tests/io/test_pyarrow_visitor.py‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
_expression_to_complementary_pyarrow,
4040
_HasIds,
4141
_NullNaNUnmentionedTermsCollector,
42+
_primitive_to_physical,
4243
_pyarrow_schema_ensure_large_types,
4344
_pyarrow_schema_ensure_small_types,
4445
pyarrow_to_schema,
@@ -61,12 +62,14 @@
6162
LongType,
6263
MapType,
6364
NestedField,
65+
PrimitiveType,
6466
StringType,
6567
StructType,
6668
TimestampNanoType,
6769
TimestampType,
6870
TimestamptzType,
6971
TimeType,
72+
UUIDType,
7073
)
7174

7275

@@ -259,6 +262,34 @@ def test_pyarrow_variable_binary_to_iceberg(pyarrow_type: pa.DataType) -> None:
259262
assert visit(converted_iceberg_type, _ConvertToArrowSchema()) == pa.large_binary()
260263

261264

265+
@pytest.mark.parametrize(
266+
("iceberg_type", "pyarrow_type", "parquet_physical_type"),
267+
[
268+
(BooleanType(), pa.bool_(), "BOOLEAN"),
269+
(IntegerType(), pa.int32(), "INT32"),
270+
(LongType(), pa.int64(), "INT64"),
271+
(FloatType(), pa.float32(), "FLOAT"),
272+
(DoubleType(), pa.float64(), "DOUBLE"),
273+
(DateType(), pa.date32(), "INT32"),
274+
(TimeType(), pa.time64("us"), "INT64"),
275+
(TimestampType(), pa.timestamp("us"), "INT64"),
276+
(TimestamptzType(), pa.timestamp("us", tz="UTC"), "INT64"),
277+
(StringType(), pa.large_string(), "BYTE_ARRAY"),
278+
(UUIDType(), pa.uuid(), "FIXED_LEN_BYTE_ARRAY"),
279+
(BinaryType(), pa.large_binary(), "BYTE_ARRAY"),
280+
(FixedType(16), pa.binary(16), "FIXED_LEN_BYTE_ARRAY"),
281+
(DecimalType(9, 2), pa.decimal128(9, 2), "INT32"),
282+
(DecimalType(10, 2), pa.decimal128(10, 2), "INT64"),
283+
(DecimalType(19, 2), pa.decimal128(19, 2), "FIXED_LEN_BYTE_ARRAY"),
284+
],
285+
)
286+
def test_iceberg_primitive_types_map_to_pyarrow_and_parquet_physical_types(
287+
iceberg_type: PrimitiveType, pyarrow_type: pa.DataType, parquet_physical_type: str
288+
) -> None:
289+
assert schema_to_pyarrow(iceberg_type) == pyarrow_type
290+
assert _primitive_to_physical(iceberg_type) == parquet_physical_type
291+
292+
262293
def test_pyarrow_struct_to_iceberg() -> None:
263294
pyarrow_struct = pa.struct(
264295
[

0 commit comments

Comments
 (0)