You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues-all@impala.apache.org by "Tim Armstrong (Jira)" <ji...@apache.org> on 2020/06/16 19:28:00 UTC

[jira] [Commented] (IMPALA-2515) Impala rejects Parquet schemas where decimal fixed_len_byte_array columns have unnecessary padding bytes

    [ https://issues.apache.org/jira/browse/IMPALA-2515?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17137881#comment-17137881 ] 

Tim Armstrong commented on IMPALA-2515:
---------------------------------------

I was able to reproduce by hacking the parquet writer like this:
{noformat}
diff --git a/be/src/exec/parquet/hdfs-parquet-table-writer.cc b/be/src/exec/parquet/hdfs-parquet-table-writer.cc
index 722538460..b50cc70f6 100644
--- a/be/src/exec/parquet/hdfs-parquet-table-writer.cc
+++ b/be/src/exec/parquet/hdfs-parquet-table-writer.cc
@@ -412,6 +412,10 @@ class HdfsParquetTableWriter::ColumnWriter :
       plain_encoded_value_size_(
           ParquetPlainEncoder::EncodedByteSize(eval->root().type())) {
     DCHECK_NE(eval->root().type().type, TYPE_BOOLEAN);
+    if (eval->root().type().type == TYPE_DECIMAL) {
+      ++plain_encoded_value_size_;
+    }
+
   }
 
   virtual void Reset() {
diff --git a/be/src/exec/parquet/parquet-metadata-utils.cc b/be/src/exec/parquet/parquet-metadata-utils.cc
index aece0e11b..199210681 100644
--- a/be/src/exec/parquet/parquet-metadata-utils.cc
+++ b/be/src/exec/parquet/parquet-metadata-utils.cc
@@ -132,7 +132,7 @@ void SetDecimalConvertedAndLogicalType(
     const ColumnType& col_type, parquet::SchemaElement* col_schema) {
   DCHECK_EQ(col_type.type, TYPE_DECIMAL);
 
-  col_schema->__set_type_length(ParquetPlainEncoder::DecimalSize(col_type));
+  col_schema->__set_type_length(ParquetPlainEncoder::DecimalSize(col_type) + 1);
   col_schema->__set_scale(col_type.scale);
   col_schema->__set_precision(col_type.precision);
   col_schema->__set_converted_type(parquet::ConvertedType::DECIMAL);
{noformat}

> Impala rejects Parquet schemas where decimal fixed_len_byte_array columns have unnecessary padding bytes
> --------------------------------------------------------------------------------------------------------
>
>                 Key: IMPALA-2515
>                 URL: https://issues.apache.org/jira/browse/IMPALA-2515
>             Project: IMPALA
>          Issue Type: Sub-task
>          Components: Backend
>    Affects Versions: Impala 2.3.0
>            Reporter: Taras Bobrovytsky
>            Priority: Minor
>              Labels: ramp-up
>         Attachments: image-2020-02-07-11-31-38-074.png, image-2020-02-07-11-31-43-641.png, image-2020-02-07-11-33-27-944.png, image-2020-02-07-11-34-04-220.png, image-2020-02-07-11-36-31-458.png, image-2020-02-07-11-48-35-179.png
>
>
> Impala cannot read this:
> {code}
> {"name": "tmp_1",
>  "type": "fixed",
>  "size": 8,
>  "logicalType": "decimal",
>  "precision": 10,
>  "scale": 5}
> {code}
> However, this can be read:
> {code}
> {"name": "tmp_1",
>  "type": "fixed",
>  "size": 5,
>  "logicalType": "decimal",
>  "precision": 10,
>  "scale": 5}
> {code}
> Size must be precisely set to this, or Impala is unable to read the decimal column:
> {code}
> size = int(math.ceil((math.log(2, 10) + precision) / math.log(256, 10)))
> {code}
> There is nothing in the Parquet spec that says that Decimal columns must be sized precisely. Arguably it's a bug in the writer if it's doing it, because it's just wasting space.
> https://github.com/apache/parquet-format/blob/master/LogicalTypes.md#decimal



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-all-unsubscribe@impala.apache.org
For additional commands, e-mail: issues-all-help@impala.apache.org