You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2021/02/02 17:35:31 UTC

[GitHub] [spark] cloud-fan commented on a change in pull request #31284: [SPARK-34167][SQL]Reading parquet with IntDecimal written as a LongDecimal blows up

cloud-fan commented on a change in pull request #31284:
URL: https://github.com/apache/spark/pull/31284#discussion_r568797351



##########
File path: sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/parquet/ParquetIOSuite.scala
##########
@@ -1205,6 +1205,32 @@ class ParquetIOSuite extends QueryTest with ParquetTest with SharedSparkSession
       }
     }
   }
+
+  test("SPARK-34167: read LongDecimals with precision < 10, VectorizedReader off") {
+    // decimal32-written-as-64-bit.snappy.parquet was generated using a 3rd-party library. It has
+    // 10 rows of Decimal(9, 1) written as LongDecimal instead of an IntDecimal
+    readParquetFile(testFile("test-data/decimal32-written-as-64-bit.snappy.parquet"), false) {
+      df => assert(10 == df.collect().length)
+    }
+    // decimal32-written-as-64-bit-dict.snappy.parquet was generated using a 3rd-party library. It
+    // has 2048 rows of Decimal(3, 1) written as LongDecimal instead of an IntDecimal
+    readParquetFile(testFile("test-data/decimal32-written-as-64-bit-dict.snappy.parquet"), false) {
+      df => assert(2048 == df.collect().length)
+    }
+  }
+
+  test("SPARK-34167: read LongDecimals with precision < 10, VectorizedReader on") {
+    // decimal32-written-as-64-bit.snappy.parquet was generated using a 3rd-party library. It has
+    // 10 rows of Decimal(9, 1) written as LongDecimal instead of an IntDecimal
+    readParquetFile(testFile("test-data/decimal32-written-as-64-bit.snappy.parquet")) { df =>

Review comment:
       How did you generate this parquet file? The footer contains a metadata entry: `"org.apache.spark.sql.parquet.row.metadata": "{"type":"struct","fields":[{"name":"_c0","type":"decimal(9,1)","nullable":true,"metadata":{}}]}"`, which looks pretty weird as Spark can't generate such parquet files.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org