Skip to content

Commit 663ab76

Browse files
authored
Fix Regex signature types (#12690)
* Fix Regex signature types * Uncomment the shared tests in string_query.slt.part and removed tests copies everywhere else * Test `LIKE` and `MATCH` with flags; Remove new tests from regexp.slt
1 parent 35adf47 commit 663ab76

File tree

6 files changed

+41
-123
lines changed

6 files changed

+41
-123
lines changed

datafusion/functions/src/regex/regexplike.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ impl RegexpLikeFunc {
4848
signature: Signature::one_of(
4949
vec![
5050
Exact(vec![Utf8, Utf8]),
51-
Exact(vec![LargeUtf8, Utf8]),
51+
Exact(vec![LargeUtf8, LargeUtf8]),
5252
Exact(vec![Utf8, Utf8, Utf8]),
53-
Exact(vec![LargeUtf8, Utf8, Utf8]),
53+
Exact(vec![LargeUtf8, LargeUtf8, LargeUtf8]),
5454
],
5555
Volatility::Immutable,
5656
),

datafusion/functions/src/regex/regexpmatch.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ impl RegexpMatchFunc {
5454
// If that fails, it proceeds to `(LargeUtf8, Utf8)`.
5555
// TODO: Native support Utf8View for regexp_match.
5656
Exact(vec![Utf8, Utf8]),
57-
Exact(vec![LargeUtf8, Utf8]),
57+
Exact(vec![LargeUtf8, LargeUtf8]),
5858
Exact(vec![Utf8, Utf8, Utf8]),
59-
Exact(vec![LargeUtf8, Utf8, Utf8]),
59+
Exact(vec![LargeUtf8, LargeUtf8, LargeUtf8]),
6060
],
6161
Volatility::Immutable,
6262
),
@@ -131,7 +131,7 @@ pub fn regexp_match<T: OffsetSizeTrait>(args: &[ArrayRef]) -> Result<ArrayRef> {
131131
let flags = as_generic_string_array::<T>(&args[2])?;
132132

133133
if flags.iter().any(|s| s == Some("g")) {
134-
return plan_err!("regexp_match() does not support the \"global\" option")
134+
return plan_err!("regexp_match() does not support the \"global\" option");
135135
}
136136

137137
regexp::regexp_match(values, regex, Some(flags))

datafusion/sqllogictest/test_files/string/dictionary_utf8.slt

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -53,36 +53,6 @@ Xiangpeng datafusion数据融合 false true false true
5353
Raphael datafusionДатаФусион false false false false
5454
NULL NULL NULL NULL NULL NULL
5555

56-
# TODO: move it back to `string_query.slt.part` after fixing the issue
57-
# see detail: https://github.com/apache/datafusion/issues/12664
58-
query BBBB
59-
SELECT
60-
REGEXP_LIKE(ascii_1, 'an'),
61-
REGEXP_LIKE(unicode_1, 'таФ'),
62-
REGEXP_LIKE(ascii_1, NULL),
63-
REGEXP_LIKE(unicode_1, NULL)
64-
FROM test_basic_operator;
65-
----
66-
false false NULL NULL
67-
true false NULL NULL
68-
false true NULL NULL
69-
NULL NULL NULL NULL
70-
71-
# TODO: move it back to `string_query.slt.part` after fixing the issue
72-
# see detail: https://github.com/apache/datafusion/issues/12664
73-
query ????
74-
SELECT
75-
REGEXP_MATCH(ascii_1, 'an'),
76-
REGEXP_MATCH(unicode_1, 'таФ'),
77-
REGEXP_MATCH(ascii_1, NULL),
78-
REGEXP_MATCH(unicode_1, NULL)
79-
FROM test_basic_operator;
80-
----
81-
NULL NULL NULL NULL
82-
[an] NULL NULL NULL
83-
NULL [таФ] NULL NULL
84-
NULL NULL NULL NULL
85-
8656
#
8757
# common test for string-like functions and operators
8858
#

datafusion/sqllogictest/test_files/string/string.slt

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -63,36 +63,6 @@ Xiangpeng datafusion数据融合 false true false true
6363
Raphael datafusionДатаФусион false false false false
6464
NULL NULL NULL NULL NULL NULL
6565

66-
# TODO: move it back to `string_query.slt.part` after fixing the issue
67-
# see detail: https://github.com/apache/datafusion/issues/12664
68-
query BBBB
69-
SELECT
70-
REGEXP_LIKE(ascii_1, 'an'),
71-
REGEXP_LIKE(unicode_1, 'таФ'),
72-
REGEXP_LIKE(ascii_1, NULL),
73-
REGEXP_LIKE(unicode_1, NULL)
74-
FROM test_basic_operator;
75-
----
76-
false false NULL NULL
77-
true false NULL NULL
78-
false true NULL NULL
79-
NULL NULL NULL NULL
80-
81-
# TODO: move it back to `string_query.slt.part` after fixing the issue
82-
# see detail: https://github.com/apache/datafusion/issues/12664
83-
query ????
84-
SELECT
85-
REGEXP_MATCH(ascii_1, 'an'),
86-
REGEXP_MATCH(unicode_1, 'таФ'),
87-
REGEXP_MATCH(ascii_1, NULL),
88-
REGEXP_MATCH(unicode_1, NULL)
89-
FROM test_basic_operator;
90-
----
91-
NULL NULL NULL NULL
92-
[an] NULL NULL NULL
93-
NULL [таФ] NULL NULL
94-
NULL NULL NULL NULL
95-
9666
# TODO: move it back to `string_query.slt.part` after fixing the issue
9767
# see detail: https://github.com/apache/datafusion/issues/12670
9868
query IIIIII

datafusion/sqllogictest/test_files/string/string_query.slt.part

Lines changed: 36 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -856,39 +856,47 @@ NULL NULL
856856
# Test REGEXP_LIKE
857857
# --------------------------------------
858858

859-
# TODO: LargeString does not support REGEXP_LIKE. Enable this after fixing the issue
860-
# see issue: https://github.com/apache/datafusion/issues/12664
861-
#query BBBB
862-
#SELECT
863-
# REGEXP_LIKE(ascii_1, 'an'),
864-
# REGEXP_LIKE(unicode_1, 'таФ'),
865-
# REGEXP_LIKE(ascii_1, NULL),
866-
# REGEXP_LIKE(unicode_1, NULL)
867-
#FROM test_basic_operator;
868-
#----
869-
#false false NULL NULL
870-
#true false NULL NULL
871-
#false true NULL NULL
872-
#NULL NULL NULL NULL
859+
query BBBBBBBB
860+
SELECT
861+
-- without flags
862+
REGEXP_LIKE(ascii_1, 'an'),
863+
REGEXP_LIKE(unicode_1, 'таФ'),
864+
REGEXP_LIKE(ascii_1, NULL),
865+
REGEXP_LIKE(unicode_1, NULL),
866+
-- with flags
867+
REGEXP_LIKE(ascii_1, 'AN', 'i'),
868+
REGEXP_LIKE(unicode_1, 'ТаФ', 'i'),
869+
REGEXP_LIKE(ascii_1, NULL, 'i'),
870+
REGEXP_LIKE(unicode_1, NULL, 'i')
871+
FROM test_basic_operator;
872+
----
873+
false false NULL NULL true false NULL NULL
874+
true false NULL NULL true false NULL NULL
875+
false true NULL NULL false true NULL NULL
876+
NULL NULL NULL NULL NULL NULL NULL NULL
873877

874878
# --------------------------------------
875879
# Test REGEXP_MATCH
876880
# --------------------------------------
877881

878-
# TODO: LargeString does not support REGEXP_MATCH. Enable this after fixing the issue
879-
# see issue: https://github.com/apache/datafusion/issues/12664
880-
#query ????
881-
#SELECT
882-
# REGEXP_MATCH(ascii_1, 'an'),
883-
# REGEXP_MATCH(unicode_1, 'таФ'),
884-
# REGEXP_MATCH(ascii_1, NULL),
885-
# REGEXP_MATCH(unicode_1, NULL)
886-
#FROM test_basic_operator;
887-
#----
888-
#NULL NULL NULL NULL
889-
#[an] NULL NULL NULL
890-
#NULL [таФ] NULL NULL
891-
#NULL NULL NULL NULL
882+
query ????????
883+
SELECT
884+
-- without flags
885+
REGEXP_MATCH(ascii_1, 'an'),
886+
REGEXP_MATCH(unicode_1, 'ТаФ'),
887+
REGEXP_MATCH(ascii_1, NULL),
888+
REGEXP_MATCH(unicode_1, NULL),
889+
-- with flags
890+
REGEXP_MATCH(ascii_1, 'AN', 'i'),
891+
REGEXP_MATCH(unicode_1, 'таФ', 'i'),
892+
REGEXP_MATCH(ascii_1, NULL, 'i'),
893+
REGEXP_MATCH(unicode_1, NULL, 'i')
894+
FROM test_basic_operator;
895+
----
896+
NULL NULL NULL NULL [An] NULL NULL NULL
897+
[an] NULL NULL NULL [an] NULL NULL NULL
898+
NULL NULL NULL NULL NULL [таФ] NULL NULL
899+
NULL NULL NULL NULL NULL NULL NULL NULL
892900

893901
# --------------------------------------
894902
# Test REPEAT

datafusion/sqllogictest/test_files/string/string_view.slt

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -50,36 +50,6 @@ false false
5050
false true
5151
NULL NULL
5252

53-
# TODO: move it back to `string_query.slt.part` after fixing the issue
54-
# see detail: https://github.com/apache/datafusion/issues/12664
55-
query BBBB
56-
SELECT
57-
REGEXP_LIKE(ascii_1, 'an'),
58-
REGEXP_LIKE(unicode_1, 'таФ'),
59-
REGEXP_LIKE(ascii_1, NULL),
60-
REGEXP_LIKE(unicode_1, NULL)
61-
FROM test_basic_operator;
62-
----
63-
false false NULL NULL
64-
true false NULL NULL
65-
false true NULL NULL
66-
NULL NULL NULL NULL
67-
68-
# TODO: move it back to `string_query.slt.part` after fixing the issue
69-
# see detail: https://github.com/apache/datafusion/issues/12664
70-
query ????
71-
SELECT
72-
REGEXP_MATCH(ascii_1, 'an'),
73-
REGEXP_MATCH(unicode_1, 'таФ'),
74-
REGEXP_MATCH(ascii_1, NULL),
75-
REGEXP_MATCH(unicode_1, NULL)
76-
FROM test_basic_operator;
77-
----
78-
NULL NULL NULL NULL
79-
[an] NULL NULL NULL
80-
NULL [таФ] NULL NULL
81-
NULL NULL NULL NULL
82-
8353
# TODO: move it back to `string_query.slt.part` after fixing the issue
8454
# see detail: https://github.com/apache/datafusion/issues/12670
8555
query IIIIII

0 commit comments

Comments
 (0)