From 25536028cd44249df50d2122498ce0c152831842 Mon Sep 17 00:00:00 2001 From: Dylan Chen Date: Thu, 5 Sep 2024 17:15:30 +0800 Subject: [PATCH] decimal(28,10) --- src/common/src/array/arrow/arrow_iceberg.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/common/src/array/arrow/arrow_iceberg.rs b/src/common/src/array/arrow/arrow_iceberg.rs index ff23bc102ee6..3ca0decc66e8 100644 --- a/src/common/src/array/arrow/arrow_iceberg.rs +++ b/src/common/src/array/arrow/arrow_iceberg.rs @@ -26,6 +26,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 @@ -113,8 +116,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) }