diff --git a/velox/dwio/parquet/writer/Writer.cpp b/velox/dwio/parquet/writer/Writer.cpp index a9e364b71ad9..a7104d4f80f0 100644 --- a/velox/dwio/parquet/writer/Writer.cpp +++ b/velox/dwio/parquet/writer/Writer.cpp @@ -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)); + } 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( - 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);