sadikovi commented on a change in pull request #34462:
URL: https://github.com/apache/spark/pull/34462#discussion_r741498183
##########
File path:
sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/parquet/ParquetSchemaSuite.scala
##########
@@ -388,6 +391,27 @@ class ParquetSchemaSuite extends ParquetSchemaTest {
}
}
+ test("SPARK-37191: Schema merging for DecimalType with different precision
but the same scale") {
+ import testImplicits._
+
+ withTempPath { dir =>
+ val path = dir.getCanonicalPath
+
+ val data1 = spark.sparkContext.parallelize(Seq(Row(new
BigDecimal("123456789.11"))), 1)
+ val schema1 = StructType(StructField("col", DecimalType(12, 2)) :: Nil)
+
+ val data2 = spark.sparkContext.parallelize(Seq(Row(new
BigDecimal("1234567890000.11"))), 1)
+ val schema2 = StructType(StructField("col", DecimalType(17, 2)) :: Nil)
+
+ spark.createDataFrame(data1, schema1).write.parquet(path)
+ spark.createDataFrame(data2, schema2).write.mode("append").parquet(path)
+
+ val res = spark.read.option("mergeSchema", "true").parquet(path)
+ assert(res.schema("col").dataType == DecimalType(17, 2))
+ res.foreach(_ => ()) // must not throw exception
Review comment:
ParquetSchemaSuite did not have `checkAnswer` so I left it as is
originally. This has been updated since, I moved the test to ParquetQuerySuite
and added `withAllParquetReaders` to test against all of the parquet readers.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]