Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanc-n committed Nov 14, 2024
1 parent 7c83e8c commit eaa6208
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 135 deletions.
6 changes: 4 additions & 2 deletions datafusion/functions/src/regex/regexpmatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,10 @@ impl RegexpMatchFunc {
// For example, given input `(Utf8View, Utf8)`, it first tries coercing to `(Utf8, Utf8)`.
// If that fails, it proceeds to `(LargeUtf8, Utf8)`.
// TODO: Native support Utf8View for regexp_match.
TypeSignature::String(2),
TypeSignature::String(3),
TypeSignature::Exact(vec![Utf8, Utf8]),
TypeSignature::Exact(vec![LargeUtf8, LargeUtf8]),
TypeSignature::Exact(vec![Utf8, Utf8, Utf8]),
TypeSignature::Exact(vec![LargeUtf8, LargeUtf8, LargeUtf8]),
],
Volatility::Immutable,
),
Expand Down
36 changes: 36 additions & 0 deletions datafusion/sqllogictest/test_files/expr.slt
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,42 @@ SELECT ltrim(NULL, 'xyz')
----
NULL

# implicit casting with TypeSignature test
query T
SELECT ltrim(NULL, NULL)
----
NULL

query T
SELECT ltrim(12345, '1')
----
2345

query T
SELECT ltrim(10020, '0')
----
10020

query T
SELECT ltrim(12.345, '12')
----
.345

query T
SELECT ltrim(0.00123, '0.')
----
123

query T
SELECT ltrim(true, 't')
----
rue

query T
SELECT ltrim(false, 'f')
----
alse

query I
SELECT octet_length('')
----
Expand Down
130 changes: 0 additions & 130 deletions datafusion/sqllogictest/test_files/regexp.slt
Original file line number Diff line number Diff line change
Expand Up @@ -269,136 +269,6 @@ SELECT regexp_match('(?<=[A-Z]\w )Smith', 'John Smith', 'i');
----
NULL

query ?
SELECT regexp_match(12345, '(\d{5})');
----
[12345]

query ?
SELECT regexp_match(arrow_cast(12345, 'Int64'), '(\d{5})');
----
[12345]

query ?
SELECT regexp_match(arrow_cast(-12345, 'Int32'), '^-\d{5}$');
----
[-12345]

query ?
SELECT regexp_match(arrow_cast(1234567890123, 'Int64'), '(\d{13})');
----
[1234567890123]

query ?
SELECT regexp_match(arrow_cast(12345, 'Int64'), '(\d{6})');
----
NULL

query ?
SELECT regexp_match(arrow_cast(123.45, 'Float32'), '(\d+\.\d+)');
----
[123.45]

query ?
SELECT regexp_match(arrow_cast(100.0, 'Float32'), '^100\.0$');
----
[100.0]

query ?
SELECT regexp_match(arrow_cast(-456.78, 'Float32'), '^-\d+\.\d+$');
----
[-456.78]

query ?
SELECT regexp_match(arrow_cast(123456.789012, 'Float64'), '(\d+\.\d{6})');
----
[123456.789012]

query ?
SELECT regexp_match(arrow_cast(789.0, 'Float64'), '789\.00');
----
NULL

query ?
SELECT regexp_match(arrow_cast(TRUE, 'Boolean'), '(true|false)');
----
[true]

query ?
SELECT regexp_match(arrow_cast(FALSE, 'Boolean'), '(true|false)');
----
[false]

query ?
SELECT regexp_match(arrow_cast(TRUE, 'Boolean'), '^true$');
----
[true]

query ?
SELECT regexp_match(arrow_cast(FALSE, 'Boolean'), '^false$');
----
[false]

query ?
SELECT regexp_match('abc-123', arrow_cast(123, 'Int32'));
----
[123]

query ?
SELECT regexp_match('abc-true', arrow_cast(TRUE, 'Boolean'));
----
[true]

query ?
SELECT regexp_match('value-456.78', arrow_cast(456.78, 'Float64'));
----
[456.78]

query ?
SELECT regexp_match(arrow_cast(789, 'Int32'), arrow_cast(789.0, 'Float64'));
----
NULL

query ?
SELECT regexp_match(arrow_cast(456.0, 'Float32'), arrow_cast(FALSE, 'Boolean'));
----
NULL

query ?
SELECT regexp_match(arrow_cast(NULL, 'Int32'), '.*-(\d)');
----
NULL

query ?
SELECT regexp_match('aaa-0', arrow_cast(NULL, 'Boolean'));
----
NULL

query ?
SELECT regexp_match(arrow_cast(NULL, 'Float32'), arrow_cast(NULL, 'Boolean'));
----
NULL

query ?
SELECT regexp_match(arrow_cast(0, 'Int32'), '^0$');
----
[0]

query ?
SELECT regexp_match(arrow_cast(FALSE, 'Boolean'), '^false$');
----
[false]

query ?
SELECT regexp_match(arrow_cast(123.456, 'Float64'), '^123\.456$');
----
[123.456]

query ?
SELECT regexp_match(arrow_cast(-789.012, 'Float64'), '^-\d+\.\d{3}$');
----
[-789.012]

# ported test
query ?
SELECT regexp_match('aaa-555', '.*-(\d*)');
Expand Down
3 changes: 0 additions & 3 deletions datafusion/sqllogictest/test_files/scalar.slt
Original file line number Diff line number Diff line change
Expand Up @@ -1940,9 +1940,6 @@ select position('' in '')
----
1

query error DataFusion error: Error during planning: Error during planning: The signature expected NativeType::String but received NativeType::Int64
select position(1 in 1)

query I
select strpos('abc', 'c');
----
Expand Down

0 comments on commit eaa6208

Please sign in to comment.