Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Regex signature types #12690

Merged
merged 4 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions datafusion/functions/src/regex/regexplike.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ impl RegexpLikeFunc {
signature: Signature::one_of(
vec![
Exact(vec![Utf8, Utf8]),
Exact(vec![LargeUtf8, Utf8]),
Exact(vec![LargeUtf8, LargeUtf8]),
Exact(vec![Utf8, Utf8, Utf8]),
Exact(vec![LargeUtf8, Utf8, Utf8]),
Exact(vec![LargeUtf8, LargeUtf8, LargeUtf8]),
],
Volatility::Immutable,
),
Expand Down
6 changes: 3 additions & 3 deletions datafusion/functions/src/regex/regexpmatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ impl RegexpMatchFunc {
// If that fails, it proceeds to `(LargeUtf8, Utf8)`.
// TODO: Native support Utf8View for regexp_match.
Exact(vec![Utf8, Utf8]),
Exact(vec![LargeUtf8, Utf8]),
Exact(vec![LargeUtf8, LargeUtf8]),
Exact(vec![Utf8, Utf8, Utf8]),
Exact(vec![LargeUtf8, Utf8, Utf8]),
Exact(vec![LargeUtf8, LargeUtf8, LargeUtf8]),
],
Volatility::Immutable,
),
Expand Down Expand Up @@ -131,7 +131,7 @@ pub fn regexp_match<T: OffsetSizeTrait>(args: &[ArrayRef]) -> Result<ArrayRef> {
let flags = as_generic_string_array::<T>(&args[2])?;

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

regexp::regexp_match(values, regex, Some(flags))
Expand Down
30 changes: 0 additions & 30 deletions datafusion/sqllogictest/test_files/string/dictionary_utf8.slt
Original file line number Diff line number Diff line change
Expand Up @@ -53,36 +53,6 @@ Xiangpeng datafusion数据融合 false true false true
Raphael datafusionДатаФусион false false false false
NULL NULL NULL NULL NULL NULL

# TODO: move it back to `string_query.slt.part` after fixing the issue
# see detail: https://github.com/apache/datafusion/issues/12664
query BBBB
SELECT
REGEXP_LIKE(ascii_1, 'an'),
REGEXP_LIKE(unicode_1, 'таФ'),
REGEXP_LIKE(ascii_1, NULL),
REGEXP_LIKE(unicode_1, NULL)
FROM test_basic_operator;
----
false false NULL NULL
true false NULL NULL
false true NULL NULL
NULL NULL NULL NULL

# TODO: move it back to `string_query.slt.part` after fixing the issue
# see detail: https://github.com/apache/datafusion/issues/12664
query ????
SELECT
REGEXP_MATCH(ascii_1, 'an'),
REGEXP_MATCH(unicode_1, 'таФ'),
REGEXP_MATCH(ascii_1, NULL),
REGEXP_MATCH(unicode_1, NULL)
FROM test_basic_operator;
----
NULL NULL NULL NULL
[an] NULL NULL NULL
NULL [таФ] NULL NULL
NULL NULL NULL NULL

#
# common test for string-like functions and operators
#
Expand Down
30 changes: 0 additions & 30 deletions datafusion/sqllogictest/test_files/string/string.slt
Original file line number Diff line number Diff line change
Expand Up @@ -63,36 +63,6 @@ Xiangpeng datafusion数据融合 false true false true
Raphael datafusionДатаФусион false false false false
NULL NULL NULL NULL NULL NULL

# TODO: move it back to `string_query.slt.part` after fixing the issue
# see detail: https://github.com/apache/datafusion/issues/12664
query BBBB
SELECT
REGEXP_LIKE(ascii_1, 'an'),
REGEXP_LIKE(unicode_1, 'таФ'),
REGEXP_LIKE(ascii_1, NULL),
REGEXP_LIKE(unicode_1, NULL)
FROM test_basic_operator;
----
false false NULL NULL
true false NULL NULL
false true NULL NULL
NULL NULL NULL NULL

# TODO: move it back to `string_query.slt.part` after fixing the issue
# see detail: https://github.com/apache/datafusion/issues/12664
query ????
SELECT
REGEXP_MATCH(ascii_1, 'an'),
REGEXP_MATCH(unicode_1, 'таФ'),
REGEXP_MATCH(ascii_1, NULL),
REGEXP_MATCH(unicode_1, NULL)
FROM test_basic_operator;
----
NULL NULL NULL NULL
[an] NULL NULL NULL
NULL [таФ] NULL NULL
NULL NULL NULL NULL

# TODO: move it back to `string_query.slt.part` after fixing the issue
# see detail: https://github.com/apache/datafusion/issues/12670
query IIIIII
Expand Down
64 changes: 36 additions & 28 deletions datafusion/sqllogictest/test_files/string/string_query.slt.part
Original file line number Diff line number Diff line change
Expand Up @@ -856,39 +856,47 @@ NULL NULL
# Test REGEXP_LIKE
# --------------------------------------

# TODO: LargeString does not support REGEXP_LIKE. Enable this after fixing the issue
# see issue: https://github.com/apache/datafusion/issues/12664
#query BBBB
#SELECT
# REGEXP_LIKE(ascii_1, 'an'),
# REGEXP_LIKE(unicode_1, 'таФ'),
# REGEXP_LIKE(ascii_1, NULL),
# REGEXP_LIKE(unicode_1, NULL)
#FROM test_basic_operator;
#----
#false false NULL NULL
#true false NULL NULL
#false true NULL NULL
#NULL NULL NULL NULL
query BBBBBBBB
SELECT
-- without flags
REGEXP_LIKE(ascii_1, 'an'),
REGEXP_LIKE(unicode_1, 'таФ'),
REGEXP_LIKE(ascii_1, NULL),
REGEXP_LIKE(unicode_1, NULL),
-- with flags
REGEXP_LIKE(ascii_1, 'AN', 'i'),
REGEXP_LIKE(unicode_1, 'ТаФ', 'i'),
REGEXP_LIKE(ascii_1, NULL, 'i'),
REGEXP_LIKE(unicode_1, NULL, 'i')
FROM test_basic_operator;
----
false false NULL NULL true false NULL NULL
true false NULL NULL true false NULL NULL
false true NULL NULL false true NULL NULL
NULL NULL NULL NULL NULL NULL NULL NULL

# --------------------------------------
# Test REGEXP_MATCH
# --------------------------------------

# TODO: LargeString does not support REGEXP_MATCH. Enable this after fixing the issue
# see issue: https://github.com/apache/datafusion/issues/12664
#query ????
#SELECT
# REGEXP_MATCH(ascii_1, 'an'),
# REGEXP_MATCH(unicode_1, 'таФ'),
# REGEXP_MATCH(ascii_1, NULL),
# REGEXP_MATCH(unicode_1, NULL)
#FROM test_basic_operator;
#----
#NULL NULL NULL NULL
#[an] NULL NULL NULL
#NULL [таФ] NULL NULL
#NULL NULL NULL NULL
query ????????
SELECT
-- without flags
REGEXP_MATCH(ascii_1, 'an'),
REGEXP_MATCH(unicode_1, 'ТаФ'),
REGEXP_MATCH(ascii_1, NULL),
REGEXP_MATCH(unicode_1, NULL),
-- with flags
REGEXP_MATCH(ascii_1, 'AN', 'i'),
REGEXP_MATCH(unicode_1, 'таФ', 'i'),
REGEXP_MATCH(ascii_1, NULL, 'i'),
REGEXP_MATCH(unicode_1, NULL, 'i')
FROM test_basic_operator;
----
NULL NULL NULL NULL [An] NULL NULL NULL
[an] NULL NULL NULL [an] NULL NULL NULL
NULL NULL NULL NULL NULL [таФ] NULL NULL
NULL NULL NULL NULL NULL NULL NULL NULL

# --------------------------------------
# Test REPEAT
Expand Down
30 changes: 0 additions & 30 deletions datafusion/sqllogictest/test_files/string/string_view.slt
Original file line number Diff line number Diff line change
Expand Up @@ -50,36 +50,6 @@ false false
false true
NULL NULL

# TODO: move it back to `string_query.slt.part` after fixing the issue
# see detail: https://github.com/apache/datafusion/issues/12664
query BBBB
SELECT
REGEXP_LIKE(ascii_1, 'an'),
REGEXP_LIKE(unicode_1, 'таФ'),
REGEXP_LIKE(ascii_1, NULL),
REGEXP_LIKE(unicode_1, NULL)
FROM test_basic_operator;
----
false false NULL NULL
true false NULL NULL
false true NULL NULL
NULL NULL NULL NULL

# TODO: move it back to `string_query.slt.part` after fixing the issue
# see detail: https://github.com/apache/datafusion/issues/12664
query ????
SELECT
REGEXP_MATCH(ascii_1, 'an'),
REGEXP_MATCH(unicode_1, 'таФ'),
REGEXP_MATCH(ascii_1, NULL),
REGEXP_MATCH(unicode_1, NULL)
FROM test_basic_operator;
----
NULL NULL NULL NULL
[an] NULL NULL NULL
NULL [таФ] NULL NULL
NULL NULL NULL NULL

# TODO: move it back to `string_query.slt.part` after fixing the issue
# see detail: https://github.com/apache/datafusion/issues/12670
query IIIIII
Expand Down