Skip to content

Commit 85029c5

Browse files
committed
test: cover empty and all-null subject vectors in RegExpLikeUDF unit suite
1 parent 760cd94 commit 85029c5

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

spark/src/test/scala/org/apache/comet/udf/RegExpLikeUDFSuite.scala

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,4 +88,39 @@ class RegExpLikeUDFSuite extends AnyFunSuite {
8888
allocator.close()
8989
}
9090
}
91+
92+
test("empty subject vector yields empty result") {
93+
val allocator = new RootAllocator(Long.MaxValue)
94+
try {
95+
val subject = varchar(allocator, Seq.empty)
96+
val pattern = scalarPattern(allocator, "\\d+")
97+
98+
val out = new RegExpLikeUDF()
99+
.evaluate(Array[ValueVector](subject, pattern))
100+
.asInstanceOf[BitVector]
101+
102+
assert(out.getValueCount === 0)
103+
out.close(); subject.close(); pattern.close()
104+
} finally {
105+
allocator.close()
106+
}
107+
}
108+
109+
test("all-null subject column produces all-null bitmap") {
110+
val allocator = new RootAllocator(Long.MaxValue)
111+
try {
112+
val subject = varchar(allocator, Seq(null, null, null))
113+
val pattern = scalarPattern(allocator, ".*")
114+
115+
val out = new RegExpLikeUDF()
116+
.evaluate(Array[ValueVector](subject, pattern))
117+
.asInstanceOf[BitVector]
118+
119+
assert(out.getValueCount === 3)
120+
assert(out.isNull(0) && out.isNull(1) && out.isNull(2))
121+
out.close(); subject.close(); pattern.close()
122+
} finally {
123+
allocator.close()
124+
}
125+
}
91126
}

0 commit comments

Comments
 (0)