From f4740121e525452055c0a0138b23db742a8d7682 Mon Sep 17 00:00:00 2001 From: Yubo Xu Date: Mon, 4 May 2026 22:07:09 -0700 Subject: [PATCH] test: add unhex dictionary coverage --- .../apache/comet/CometExpressionSuite.scala | 43 +++++++++++++------ 1 file changed, 30 insertions(+), 13 deletions(-) diff --git a/spark/src/test/scala/org/apache/comet/CometExpressionSuite.scala b/spark/src/test/scala/org/apache/comet/CometExpressionSuite.scala index 4fcaa550ae..3dc72745b2 100644 --- a/spark/src/test/scala/org/apache/comet/CometExpressionSuite.scala +++ b/spark/src/test/scala/org/apache/comet/CometExpressionSuite.scala @@ -1544,22 +1544,39 @@ class CometExpressionSuite extends CometTestBase with AdaptiveSparkPlanHelper { test("unhex") { val table = "unhex_table" - withTable(table) { - sql(s"create table $table(col string) using parquet") + Seq(false, true).foreach { dictionaryEnabled => + withSQLConf("parquet.enable.dictionary" -> dictionaryEnabled.toString) { + withTable(table) { + sql(s"create table $table(col string) using parquet") - sql(s"""INSERT INTO $table VALUES - |('537061726B2053514C'), - |('737472696E67'), - |('\\0'), - |(''), - |('###'), - |('G123'), - |('hello'), - |('A1B'), - |('0A1B')""".stripMargin) + sql(s"""INSERT INTO $table VALUES + |('537061726B2053514C'), + |('537061726B2053514C'), + |('737472696E67'), + |('737472696E67'), + |('\\0'), + |(''), + |('###'), + |('G123'), + |('hello'), + |('A1B'), + |('0A1B')""".stripMargin) - checkSparkAnswerAndOperator(s"SELECT unhex(col) FROM $table") + checkSparkAnswerAndOperator(s"SELECT unhex(col) FROM $table") + } + } } + + Seq(false, true).foreach { dictionaryEnabled => + withTempDir { dir => + val path = new Path(dir.toURI.toString, "test.parquet") + makeParquetFileAllPrimitiveTypes(path, dictionaryEnabled = dictionaryEnabled, 1000) + withParquetTable(path.toString, table) { + checkSparkAnswerAndOperator(s"SELECT unhex(_8) FROM $table") + } + } + } + } test("EqualNullSafe should preserve comet filter") {