Skip to content

Commit 8ededbf

Browse files
committed
Move back to decimal128
1 parent 963a599 commit 8ededbf

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

pyiceberg/io/pyarrow.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -636,14 +636,13 @@ def visit_fixed(self, fixed_type: FixedType) -> pa.DataType:
636636
return pa.binary(len(fixed_type))
637637

638638
def visit_decimal(self, decimal_type: DecimalType) -> pa.DataType:
639-
if decimal_type.precision <= 9:
640-
return pa.decimal32(decimal_type.precision, decimal_type.scale)
641-
elif decimal_type.precision <= 18:
642-
return pa.decimal64(decimal_type.precision, decimal_type.scale)
643-
elif decimal_type.precision <= 38:
644-
return pa.decimal128(decimal_type.precision, decimal_type.scale)
645-
else:
646-
raise ValueError(f"Precision above 38 is not supported: {decimal_type.precision}")
639+
# It looks like decimal{32,64} is not fully implemented:
640+
# https://github.com/apache/arrow/issues/25483
641+
# https://github.com/apache/arrow/issues/43956
642+
# However, if we keep it as 128 in memory, and based on the
643+
# precision/scale Arrow will map it to INT{32,64}
644+
# https://github.com/apache/arrow/blob/598938711a8376cbfdceaf5c77ab0fd5057e6c02/cpp/src/parquet/arrow/schema.cc#L380-L392
645+
return pa.decimal128(decimal_type.precision, decimal_type.scale)
647646

648647
def visit_boolean(self, _: BooleanType) -> pa.DataType:
649648
return pa.bool_()

0 commit comments

Comments
 (0)