Skip to content

Commit 1cee97b

Browse files
andygroveclaude
andcommitted
test: Add additional contains expression tests
Add test coverage for null haystack, case sensitivity, and both-columns (array-array) path for the optimized contains implementation. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 7943199 commit 1cee97b

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1181,6 +1181,21 @@ class CometExpressionSuite extends CometTestBase with AdaptiveSparkPlanHelper {
11811181
// Test with pattern at end
11821182
val queryEnd = sql(s"select id from $table where contains (name, 'Smith')")
11831183
checkSparkAnswerAndOperator(queryEnd)
1184+
1185+
// Test with null haystack
1186+
sql(s"insert into $table values(6, null)")
1187+
checkSparkAnswerAndOperator(sql(s"select id, contains(name, 'Rose') from $table"))
1188+
1189+
// Test case sensitivity (should not match)
1190+
checkSparkAnswerAndOperator(sql(s"select id from $table where contains(name, 'james')"))
1191+
}
1192+
}
1193+
1194+
test("contains with both columns") {
1195+
withParquetTable(
1196+
Seq(("hello world", "world"), ("foo bar", "baz"), ("abc", ""), (null, "x"), ("test", null)),
1197+
"tbl") {
1198+
checkSparkAnswerAndOperator(sql("select contains(_1, _2) from tbl"))
11841199
}
11851200
}
11861201

0 commit comments

Comments
 (0)