Skip to content

Commit

Permalink
feat(nimtable): fix decimal(28, 10) (#18424)
Browse files Browse the repository at this point in the history
  • Loading branch information
chenzl25 authored and Li0k committed Oct 14, 2024
1 parent 4041397 commit 77311d1
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/common/src/array/arrow/arrow_iceberg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ use crate::types::StructType;

pub struct IcebergArrowConvert;

const NIMTABLE_DECIMAL_PRECISION: u8 = 28;
const NIMTABLE_DECIMAL_SCALE: i8 = 10;

impl IcebergArrowConvert {
pub fn to_record_batch(
&self,
Expand Down Expand Up @@ -83,8 +86,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)
}

Expand Down

0 comments on commit 77311d1

Please sign in to comment.