diff --git a/src/common/src/array/arrow/arrow_iceberg.rs b/src/common/src/array/arrow/arrow_iceberg.rs index 80c0a3dab1667..89cdbace9cf9b 100644 --- a/src/common/src/array/arrow/arrow_iceberg.rs +++ b/src/common/src/array/arrow/arrow_iceberg.rs @@ -28,6 +28,9 @@ use { use crate::array::{Array, ArrayError, ArrayImpl, DataChunk, DataType, DecimalArray}; use crate::types::{Interval, StructType}; +const NIMTABLE_DECIMAL_PRECISION: u8 = 28; +const NIMTABLE_DECIMAL_SCALE: i8 = 10; + impl ArrowIntervalTypeTrait for ArrowIntervalType { fn to_interval(self) -> Interval { // XXX: the arrow-rs decoding is incorrect @@ -115,8 +118,13 @@ impl IcebergArrowConvert { impl ToArrow for IcebergArrowConvert { #[inline] fn decimal_type_to_arrow(&self, name: &str) -> arrow_schema::Field { + // Nimtable need a decimal type with precision and scale to be set + // We choose 28 here + // The decimal type finally will be converted to an iceberg decimal type. + // Iceberg decimal(P,S) + // Fixed-point decimal; precision P, scale S Scale is fixed, precision must be 38 or less. let data_type = - arrow_schema::DataType::Decimal128(arrow_schema::DECIMAL128_MAX_PRECISION, 0); + arrow_schema::DataType::Decimal128(NIMTABLE_DECIMAL_PRECISION, NIMTABLE_DECIMAL_SCALE); arrow_schema::Field::new(name, data_type, true) }