From b0ad61c354894d6bc61dbb802ea89f0fc06cf6c8 Mon Sep 17 00:00:00 2001 From: Andy Grove Date: Thu, 12 Dec 2024 15:30:50 -0700 Subject: [PATCH] add tests for Map and Array --- .../apache/comet/CometExpressionSuite.scala | 27 +++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/spark/src/test/scala/org/apache/comet/CometExpressionSuite.scala b/spark/src/test/scala/org/apache/comet/CometExpressionSuite.scala index d9504b34c..cce7cb20a 100644 --- a/spark/src/test/scala/org/apache/comet/CometExpressionSuite.scala +++ b/spark/src/test/scala/org/apache/comet/CometExpressionSuite.scala @@ -2276,7 +2276,7 @@ class CometExpressionSuite extends CometTestBase with AdaptiveSparkPlanHelper { } } - test("read map[int, int] from parquet") { + ignore("read map[int, int] from parquet") { withTempPath { dir => // create input file with Comet disabled withSQLConf(CometConf.COMET_ENABLED.key -> "false") { @@ -2284,7 +2284,8 @@ class CometExpressionSuite extends CometTestBase with AdaptiveSparkPlanHelper { .range(5) // Spark does not allow null as a key but does allow null as a // value, and the entire map be null - .select(when(col("id") > 1, map(col("id"), when(col("id") > 2, col("id")))).alias("map1")) + .select( + when(col("id") > 1, map(col("id"), when(col("id") > 2, col("id")))).alias("map1")) df.write.parquet(dir.toString()) } @@ -2299,6 +2300,28 @@ class CometExpressionSuite extends CometTestBase with AdaptiveSparkPlanHelper { } } + ignore("read array[int] from parquet") { + withTempPath { dir => + // create input file with Comet disabled + withSQLConf(CometConf.COMET_ENABLED.key -> "false") { + val df = spark + .range(5) + // Spark does not allow null as a key but does allow null as a + // value, and the entire map be null + .select(when(col("id") > 1, sequence(lit(0), col("id") * 2)).alias("array1")) + df.write.parquet(dir.toString()) + } + + Seq("", "parquet").foreach { v1List => + withSQLConf(SQLConf.USE_V1_SOURCE_LIST.key -> v1List) { + val df = spark.read.parquet(dir.toString()) + checkSparkAnswerAndOperator(df.select("array1")) + checkSparkAnswerAndOperator(df.select(element_at(col("array1"), lit(1)))) + } + } + } + } + test("CreateArray") { Seq(true, false).foreach { dictionaryEnabled => withTempDir { dir =>