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

HPCC-33305 Fix warning in Parquet Plugin arrow::decimal #19479

Open
wants to merge 2 commits into
base: candidate-9.10.x
Choose a base branch
from
Open
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
33 changes: 29 additions & 4 deletions plugins/parquet/parquetembed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -805,8 +805,12 @@ arrow::Status ParquetWriter::fieldToNode(const RtlFieldInfo *field, std::vector<
}
break;
case type_decimal:
arrowFields.push_back(std::make_shared<arrow::Field>(name.str(), arrow::decimal(field->type->getDecimalDigits(), field->type->getDecimalPrecision())));
{
int32_t precision = field->type->getDecimalDigits();
int32_t scale = field->type->getDecimalPrecision();
arrowFields.push_back(std::make_shared<arrow::Field>(name.str(), precision <= arrow::Decimal128Type::kMaxPrecision ? arrow::decimal128(precision, scale) : arrow::decimal256(precision, scale)));
break;
}
case type_data:
if (field->type->length > 0)
{
Expand Down Expand Up @@ -1916,22 +1920,43 @@ void ParquetRecordBinder::processReal(double value, const RtlFieldInfo *field)
void ParquetRecordBinder::addDecimalFieldToBuilder(rtlDataAttr *decText, size32_t bytes, int32_t digits, int32_t precision, const RtlFieldInfo *field)
{
arrow::ArrayBuilder *fieldBuilder = parquetWriter->getFieldBuilder(field);
if (fieldBuilder->type()->id() == arrow::Type::DECIMAL128)
switch (fieldBuilder->type()->id())
{
case arrow::Type::DECIMAL32:
{
arrow::Decimal32Builder *decimal32Builder = static_cast<arrow::Decimal32Builder *>(fieldBuilder);
arrow::Decimal32 decimal32;
reportIfFailure(arrow::Decimal32::FromString(std::string_view(decText->getstr(), bytes), &decimal32, &digits, &precision));
reportIfFailure(decimal32Builder->Append(decimal32));
break;
}
case arrow::Type::DECIMAL64:
{
arrow::Decimal64Builder *decimal64Builder = static_cast<arrow::Decimal64Builder *>(fieldBuilder);
arrow::Decimal64 decimal64;
reportIfFailure(arrow::Decimal64::FromString(std::string_view(decText->getstr(), bytes), &decimal64, &digits, &precision));
reportIfFailure(decimal64Builder->Append(decimal64));
break;
}
case arrow::Type::DECIMAL128:
{
arrow::Decimal128Builder *decimal128Builder = static_cast<arrow::Decimal128Builder *>(fieldBuilder);
arrow::Decimal128 decimal128;
reportIfFailure(arrow::Decimal128::FromString(std::string_view(decText->getstr(), bytes), &decimal128, &digits, &precision));
reportIfFailure(decimal128Builder->Append(decimal128));
break;
}
else if (fieldBuilder->type()->id() == arrow::Type::DECIMAL256)
case arrow::Type::DECIMAL256:
{
arrow::Decimal256Builder *decimal256Builder = static_cast<arrow::Decimal256Builder *>(fieldBuilder);
arrow::Decimal256 decimal256;
reportIfFailure(arrow::Decimal256::FromString(std::string_view(decText->getstr(), bytes), &decimal256, &digits, &precision));
reportIfFailure(decimal256Builder->Append(decimal256));
break;
}
else
default:
failx("Incorrect type for Decimal field %s: %s", field->name, fieldBuilder->type()->ToString().c_str());
}
}

/**
Expand Down
Loading