Skip to content

Commit b7c54f4

Browse files
committed
Add fallback test for lookahead expressions.
Signed-off-by: Igor Peshansky <ipeshansky@nvidia.com>
1 parent 5477e23 commit b7c54f4

2 files changed

Lines changed: 22 additions & 0 deletions

File tree

integration_tests/src/main/python/regexp_test.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1040,6 +1040,16 @@ def test_rlike_fallback_possessive_quantifier():
10401040
'RLike',
10411041
conf=_regexp_conf)
10421042

1043+
@allow_non_gpu('ProjectExec', 'RLike')
1044+
def test_rlike_fallback_lookaheads():
1045+
gen = mk_str_gen('(\u20ac|\\w){0,3}a[|b*.$\r\n]{0,2}c\\w{0,3}')
1046+
for pattern in ['a(?=a*)', 'a(?!a*)']:
1047+
assert_gpu_fallback_collect(
1048+
lambda spark, pattern=pattern: unary_op_df(spark, gen).selectExpr(
1049+
f'a rlike "{pattern}"'),
1050+
'RLike',
1051+
conf=_regexp_conf)
1052+
10431053
def test_regexp_extract_all_idx_zero():
10441054
gen = mk_str_gen('[abcd]{0,3}[0-9]{0,3}-[0-9]{0,3}[abcd]{1,3}')
10451055
assert_gpu_and_cpu_are_equal_collect(

tests/src/test/scala/com/nvidia/spark/rapids/RegularExpressionParserSuite.scala

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,18 @@ class RegularExpressionParserSuite extends AnyFunSuite {
248248
RegexRepetition(RegexChar('a'), SimpleQuantifier('?')))), None))))
249249
}
250250

251+
test("lookahead group expressions") {
252+
val e = intercept[RegexUnsupportedException] {
253+
parse("a(?=abc)b")
254+
}
255+
assert(e.getMessage.startsWith("Lookahead group expressions are not supported"))
256+
257+
val e = intercept[RegexUnsupportedException] {
258+
parse("a(?!abc)b")
259+
}
260+
assert(e.getMessage.startsWith("Lookahead group expressions are not supported"))
261+
}
262+
251263
test("complex expression") {
252264
val ast = parse(
253265
"^" + // start of line

0 commit comments

Comments
 (0)