-
Notifications
You must be signed in to change notification settings - Fork 1.4k
fix(parquet): Fix inserting decimal type values precision and scale #12846
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -229,7 +229,18 @@ std::shared_ptr<::arrow::Field> updateFieldNameRecursive( | |
| arrowMapType->item_field(), *mapType.valueType()); | ||
| return newField->WithType( | ||
| ::arrow::map(newKeyField->type(), newValueField->type())); | ||
| } else if (name != "") { | ||
| } else if (type.isDecimal()) { | ||
| // Parquet type is set from the column type rather than inferred from the | ||
| // field data. | ||
| auto precisionScale = getDecimalPrecisionScale(type); | ||
| if (!name.empty()) { | ||
| auto newField = field->WithName(name); | ||
| return newField->WithType( | ||
| ::arrow::decimal(precisionScale.first, precisionScale.second)); | ||
| } | ||
| return field->WithType( | ||
| ::arrow::decimal(precisionScale.first, precisionScale.second)); | ||
majetideepak marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } else if (!name.empty()) { | ||
| return field->WithName(name); | ||
| } else { | ||
| return field; | ||
|
|
@@ -437,10 +448,6 @@ dwio::common::StripeProgress getStripeProgress( | |
| * This method assumes each input `ColumnarBatch` have same schema. | ||
| */ | ||
| void Writer::write(const VectorPtr& data) { | ||
| VELOX_USER_CHECK( | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this too strong to remove this here? So this would trigger because the type is DECIMAL(8,2) but the schema type is DECIMAL(6,2)? For other types we may not have this problem. Perhaps for DECIMAL we need a separate chat to check that we allow a larger precision?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Check is done in the Java code before it comes here so I believe it should be safe to remove this check here.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should validate in Velox as well since it's a general-purpose library. |
||
| data->type()->equivalent(*schema_), | ||
| "The file schema type should be equal with the input rowvector type."); | ||
|
|
||
| VectorPtr exportData = data; | ||
| if (needFlatten(exportData)) { | ||
| BaseVector::flattenVector(exportData); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.