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

Add support for utf8view to nvl function #13382

Merged
merged 3 commits into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
1 change: 1 addition & 0 deletions datafusion/functions/src/core/nvl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ static SUPPORTED_NVL_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/nvl.slt
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,33 @@ query I
SELECT NVL(NULL, NULL);
----
NULL

query T
SELECT NVL(arrow_cast(text_field, 'Utf8View'), 'zxb') FROM test;
----
abc
def
ghij
zxb
zxc
zxb

query T
SELECT NVL(arrow_cast('a', 'Utf8View'), 'zxb');
----
a

query T
SELECT NVL('zxb', arrow_cast('a', 'Utf8View'));
----
zxb

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

query T
SELECT NVL(arrow_cast('a', 'Utf8View'), NULL);
----
a
11 changes: 9 additions & 2 deletions datafusion/sqllogictest/test_files/string/string_view.slt
Original file line number Diff line number Diff line change
Expand Up @@ -935,12 +935,19 @@ 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
## Ensure no casts for NVL
query TT
EXPLAIN SELECT NVL(column1_utf8view, 'a') as c2 FROM test;
----
logical_plan
01)Projection: nvl(test.column1_utf8view, Utf8View("a")) AS c2
02)--TableScan: test projection=[column1_utf8view]

## Ensure no casts for nullif
query error DataFusion error: SQL error: ParserError\("Expected: an SQL statement, found: logical_plan"\)
Copy link
Contributor

@jayzhan211 jayzhan211 Nov 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recheck this and found this is error, why is that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like a merge error, fixing.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was probably my bad -- sorry

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]
Expand Down