Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(nimtable): fix decimal(28, 10) #18424

Merged
merged 1 commit into from
Sep 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -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
Expand Down Expand Up @@ -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)
}

Expand Down
Loading