Skip to content

Commit

Permalink
Directly support utf8view in nullif. apache#13379 (apache#13380)
Browse files Browse the repository at this point in the history
  • Loading branch information
Omega359 authored Nov 13, 2024
1 parent 2a2de82 commit 430a67c
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 0 deletions.
1 change: 1 addition & 0 deletions datafusion/functions/src/core/nullif.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ static SUPPORTED_NULLIF_TYPES: &[DataType] = &[
DataType::Int64,
DataType::Float32,
DataType::Float64,
DataType::Utf8View,
DataType::Utf8,
DataType::LargeUtf8,
];
Expand Down
30 changes: 30 additions & 0 deletions datafusion/sqllogictest/test_files/nullif.slt
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,33 @@ query I
SELECT NULLIF(NULL, NULL);
----
NULL

query T
SELECT NULLIF(arrow_cast('a', 'Utf8View'), 'a');
----
NULL

query T
SELECT NULLIF('a', arrow_cast('a', 'Utf8View'));
----
NULL

query T
SELECT NULLIF(arrow_cast('a', 'Utf8View'), 'b');
----
a

query T
SELECT NULLIF('a', arrow_cast('b', 'Utf8View'));
----
a

query T
SELECT NULLIF(null, arrow_cast('a', 'Utf8View'));
----
NULL

query T
SELECT NULLIF(arrow_cast('a', 'Utf8View'), null);
----
a
20 changes: 20 additions & 0 deletions datafusion/sqllogictest/test_files/string/string_view.slt
Original file line number Diff line number Diff line change
Expand Up @@ -934,6 +934,26 @@ logical_plan
01)Projection: to_timestamp(test.column1_utf8view, Utf8("a,b,c,d")) AS c
02)--TableScan: test projection=[column1_utf8view]

## Ensure no casts for nullif
query TT
EXPLAIN SELECT
nullif(column1_utf8view, 'a') as c
FROM test;
----
logical_plan
01)Projection: nullif(test.column1_utf8view, Utf8View("a")) AS c
02)--TableScan: test projection=[column1_utf8view]

## Ensure no casts for nullif
query TT
EXPLAIN SELECT
nullif(column1_utf8view, column1_utf8view) as c
FROM test;
----
logical_plan
01)Projection: nullif(test.column1_utf8view, test.column1_utf8view) AS c
02)--TableScan: test projection=[column1_utf8view]

## Ensure no casts for binary operators
# `~` operator (regex match)
query TT
Expand Down

0 comments on commit 430a67c

Please sign in to comment.