Skip to content

Commit a12bf10

Browse files
committed
feat(schema conversion): add schema conversion from avro timestamp-millis
1 parent 9c99f32 commit a12bf10

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

pyiceberg/utils/schema_conversion.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
LOGICAL_FIELD_TYPE_MAPPING: Dict[Tuple[str, str], PrimitiveType] = {
7070
("date", "int"): DateType(),
7171
("time-micros", "long"): TimeType(),
72+
("timestamp-millis", "int"): TimestampType(),
7273
("timestamp-micros", "long"): TimestampType(),
7374
("uuid", "fixed"): UUIDType(),
7475
}

tests/utils/test_schema_conversion.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
NestedField,
3434
StringType,
3535
StructType,
36+
TimestampType,
3637
UnknownType,
3738
)
3839
from pyiceberg.utils.schema_conversion import AvroSchemaConversion
@@ -327,6 +328,18 @@ def test_convert_date_type() -> None:
327328
assert actual == DateType()
328329

329330

331+
def test_convert_timestamp_millis_type() -> None:
332+
avro_logical_type = {"type": "int", "logicalType": "timestamp-millis"}
333+
actual = AvroSchemaConversion()._convert_logical_type(avro_logical_type)
334+
assert actual == TimestampType()
335+
336+
337+
def test_convert_timestamp_micros_type() -> None:
338+
avro_logical_type = {"type": "int", "logicalType": "timestamp-micros"}
339+
actual = AvroSchemaConversion()._convert_logical_type(avro_logical_type)
340+
assert actual == TimestampType()
341+
342+
330343
def test_unknown_logical_type() -> None:
331344
"""Test raising a ValueError when converting an unknown logical type as part of an Avro schema conversion"""
332345
avro_logical_type = {"type": "bytes", "logicalType": "date"}

0 commit comments

Comments
 (0)