Skip to content

Commit c51b432

Browse files
Omega359alamb
andauthored
Add support for utf8view to nvl function (#13382)
* Directly support utf8view in nvl. #13381 * Fix what looks like a merge error. --------- Co-authored-by: Andrew Lamb <[email protected]>
1 parent 37b1bda commit c51b432

File tree

3 files changed

+39
-0
lines changed

3 files changed

+39
-0
lines changed

datafusion/functions/src/core/nvl.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ static SUPPORTED_NVL_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/nvl.slt

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,3 +118,33 @@ query I
118118
SELECT NVL(NULL, NULL);
119119
----
120120
NULL
121+
122+
query T
123+
SELECT NVL(arrow_cast(text_field, 'Utf8View'), 'zxb') FROM test;
124+
----
125+
abc
126+
def
127+
ghij
128+
zxb
129+
zxc
130+
zxb
131+
132+
query T
133+
SELECT NVL(arrow_cast('a', 'Utf8View'), 'zxb');
134+
----
135+
a
136+
137+
query T
138+
SELECT NVL('zxb', arrow_cast('a', 'Utf8View'));
139+
----
140+
zxb
141+
142+
query T
143+
SELECT NVL(NULL, arrow_cast('a', 'Utf8View'));
144+
----
145+
a
146+
147+
query T
148+
SELECT NVL(arrow_cast('a', 'Utf8View'), NULL);
149+
----
150+
a

datafusion/sqllogictest/test_files/string/string_view.slt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -935,6 +935,14 @@ logical_plan
935935
01)Projection: to_timestamp(test.column1_utf8view, Utf8("a,b,c,d")) AS c
936936
02)--TableScan: test projection=[column1_utf8view]
937937

938+
## Ensure no casts for NVL
939+
query TT
940+
EXPLAIN SELECT NVL(column1_utf8view, 'a') as c2 FROM test;
941+
----
942+
logical_plan
943+
01)Projection: nvl(test.column1_utf8view, Utf8View("a")) AS c2
944+
02)--TableScan: test projection=[column1_utf8view]
945+
938946
## Ensure no casts for nullif
939947
query TT
940948
EXPLAIN SELECT

0 commit comments

Comments
 (0)