From 1d76ff108a3c77f082fd17d1ec9bfd58bd6872d3 Mon Sep 17 00:00:00 2001 From: Jack Del Vecchio Date: Thu, 22 Aug 2024 18:43:43 +0000 Subject: [PATCH] Fix decimal translation --- plugins/parquet/parquetembed.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/plugins/parquet/parquetembed.cpp b/plugins/parquet/parquetembed.cpp index 8b96df70669..5b978fd8a42 100644 --- a/plugins/parquet/parquetembed.cpp +++ b/plugins/parquet/parquetembed.cpp @@ -1917,23 +1917,26 @@ void ParquetRecordBinder::processDecimal(const void *value, unsigned digits, uns rtlDataAttr decText; val.setDecimal(digits, precision, value); val.getStringX(bytes, decText.refstr()); - // unsigned numDigits; - // val.getPrecision(numDigits, precision); - // assert(numDigits <= 64 && precision <= 32); - // int32_t decDigits = (int32_t) numDigits; - // int32_t decPrecision = (int32_t) precision; + + unsigned numDigits = 0; + val.getPrecision(numDigits, precision); + assert(numDigits <= 64 && precision <= 32); + int32_t decDigits = (int32_t) numDigits; + int32_t decPrecision = (int32_t) precision; arrow::ArrayBuilder *fieldBuilder = parquetWriter->getFieldBuilder(field); if (fieldBuilder->type()->id() == arrow::Type::DECIMAL128) { arrow::Decimal128Builder *decimal128Builder = static_cast(fieldBuilder); - PARQUET_ASSIGN_OR_THROW(arrow::Decimal128 decimal128, arrow::Decimal128::FromString(std::string_view(decText.getstr(), bytes))); + arrow::Decimal128 decimal128; + reportIfFailure(arrow::Decimal128::FromString(std::string_view(decText.getstr(), bytes), &decimal128, &decDigits, &decPrecision)); reportIfFailure(decimal128Builder->Append(decimal128)); } else if (fieldBuilder->type()->id() == arrow::Type::DECIMAL256) { arrow::Decimal256Builder *decimal256Builder = static_cast(fieldBuilder); - PARQUET_ASSIGN_OR_THROW(arrow::Decimal256 decimal256, arrow::Decimal256::FromString(std::string_view(decText.getstr(), bytes))); + arrow::Decimal256 decimal256; + reportIfFailure(arrow::Decimal256::FromString(std::string_view(decText.getstr(), bytes), &decimal256, &decDigits, &decPrecision)); reportIfFailure(decimal256Builder->Append(decimal256)); } else