Skip to content

Commit dfac726

Browse files
Omega359alamb
authored andcommitted
Directly support utf8view in nullif. apache#13379 (apache#13380)
1 parent e206a34 commit dfac726

File tree

3 files changed

+51
-0
lines changed

3 files changed

+51
-0
lines changed

datafusion/functions/src/core/nullif.rs

+1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ static SUPPORTED_NULLIF_TYPES: &[DataType] = &[
4747
DataType::Int64,
4848
DataType::Float32,
4949
DataType::Float64,
50+
DataType::Utf8View,
5051
DataType::Utf8,
5152
DataType::LargeUtf8,
5253
];

datafusion/sqllogictest/test_files/nullif.slt

+30
Original file line numberDiff line numberDiff line change
@@ -101,3 +101,33 @@ query I
101101
SELECT NULLIF(NULL, NULL);
102102
----
103103
NULL
104+
105+
query T
106+
SELECT NULLIF(arrow_cast('a', 'Utf8View'), 'a');
107+
----
108+
NULL
109+
110+
query T
111+
SELECT NULLIF('a', arrow_cast('a', 'Utf8View'));
112+
----
113+
NULL
114+
115+
query T
116+
SELECT NULLIF(arrow_cast('a', 'Utf8View'), 'b');
117+
----
118+
a
119+
120+
query T
121+
SELECT NULLIF('a', arrow_cast('b', 'Utf8View'));
122+
----
123+
a
124+
125+
query T
126+
SELECT NULLIF(null, arrow_cast('a', 'Utf8View'));
127+
----
128+
NULL
129+
130+
query T
131+
SELECT NULLIF(arrow_cast('a', 'Utf8View'), null);
132+
----
133+
a

datafusion/sqllogictest/test_files/string/string_view.slt

+20
Original file line numberDiff line numberDiff line change
@@ -934,6 +934,26 @@ logical_plan
934934
01)Projection: to_timestamp(test.column1_utf8view, Utf8("a,b,c,d")) AS c
935935
02)--TableScan: test projection=[column1_utf8view]
936936

937+
## Ensure no casts for nullif
938+
query TT
939+
EXPLAIN SELECT
940+
nullif(column1_utf8view, 'a') as c
941+
FROM test;
942+
----
943+
logical_plan
944+
01)Projection: nullif(test.column1_utf8view, Utf8View("a")) AS c
945+
02)--TableScan: test projection=[column1_utf8view]
946+
947+
## Ensure no casts for nullif
948+
query TT
949+
EXPLAIN SELECT
950+
nullif(column1_utf8view, column1_utf8view) as c
951+
FROM test;
952+
----
953+
logical_plan
954+
01)Projection: nullif(test.column1_utf8view, test.column1_utf8view) AS c
955+
02)--TableScan: test projection=[column1_utf8view]
956+
937957
## Ensure no casts for binary operators
938958
# `~` operator (regex match)
939959
query TT

0 commit comments

Comments
 (0)