Skip to content

Commit 5910560

Browse files
yuboxxYubo Xu
andauthored
test: add unhex dictionary coverage (#4222)
Co-authored-by: Yubo Xu <yubox@Yubos-MacBook-Pro-3.local>
1 parent 356dd94 commit 5910560

1 file changed

Lines changed: 30 additions & 13 deletions

File tree

spark/src/test/scala/org/apache/comet/CometExpressionSuite.scala

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1544,22 +1544,39 @@ class CometExpressionSuite extends CometTestBase with AdaptiveSparkPlanHelper {
15441544

15451545
test("unhex") {
15461546
val table = "unhex_table"
1547-
withTable(table) {
1548-
sql(s"create table $table(col string) using parquet")
1547+
Seq(false, true).foreach { dictionaryEnabled =>
1548+
withSQLConf("parquet.enable.dictionary" -> dictionaryEnabled.toString) {
1549+
withTable(table) {
1550+
sql(s"create table $table(col string) using parquet")
15491551

1550-
sql(s"""INSERT INTO $table VALUES
1551-
|('537061726B2053514C'),
1552-
|('737472696E67'),
1553-
|('\\0'),
1554-
|(''),
1555-
|('###'),
1556-
|('G123'),
1557-
|('hello'),
1558-
|('A1B'),
1559-
|('0A1B')""".stripMargin)
1552+
sql(s"""INSERT INTO $table VALUES
1553+
|('537061726B2053514C'),
1554+
|('537061726B2053514C'),
1555+
|('737472696E67'),
1556+
|('737472696E67'),
1557+
|('\\0'),
1558+
|(''),
1559+
|('###'),
1560+
|('G123'),
1561+
|('hello'),
1562+
|('A1B'),
1563+
|('0A1B')""".stripMargin)
15601564

1561-
checkSparkAnswerAndOperator(s"SELECT unhex(col) FROM $table")
1565+
checkSparkAnswerAndOperator(s"SELECT unhex(col) FROM $table")
1566+
}
1567+
}
15621568
}
1569+
1570+
Seq(false, true).foreach { dictionaryEnabled =>
1571+
withTempDir { dir =>
1572+
val path = new Path(dir.toURI.toString, "test.parquet")
1573+
makeParquetFileAllPrimitiveTypes(path, dictionaryEnabled = dictionaryEnabled, 1000)
1574+
withParquetTable(path.toString, table) {
1575+
checkSparkAnswerAndOperator(s"SELECT unhex(_8) FROM $table")
1576+
}
1577+
}
1578+
}
1579+
15631580
}
15641581

15651582
test("EqualNullSafe should preserve comet filter") {

0 commit comments

Comments
 (0)