This is an automated email from the ASF dual-hosted git repository.

alamb pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/datafusion.git


The following commit(s) were added to refs/heads/main by this push:
     new c51b432089 Add support for utf8view to nvl function (#13382)
c51b432089 is described below

commit c51b432089bd7c6084650c59ecc8f017fe4debf7
Author: Bruce Ritchie <[email protected]>
AuthorDate: Fri Nov 15 14:18:22 2024 -0500

    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]>
---
 datafusion/functions/src/core/nvl.rs               |  1 +
 datafusion/sqllogictest/test_files/nvl.slt         | 30 ++++++++++++++++++++++
 .../sqllogictest/test_files/string/string_view.slt |  8 ++++++
 3 files changed, 39 insertions(+)

diff --git a/datafusion/functions/src/core/nvl.rs 
b/datafusion/functions/src/core/nvl.rs
index 16438e1b62..24b6f5fc14 100644
--- a/datafusion/functions/src/core/nvl.rs
+++ b/datafusion/functions/src/core/nvl.rs
@@ -47,6 +47,7 @@ static SUPPORTED_NVL_TYPES: &[DataType] = &[
     DataType::Int64,
     DataType::Float32,
     DataType::Float64,
+    DataType::Utf8View,
     DataType::Utf8,
     DataType::LargeUtf8,
 ];
diff --git a/datafusion/sqllogictest/test_files/nvl.slt 
b/datafusion/sqllogictest/test_files/nvl.slt
index 81e79e1eb5..daab54307c 100644
--- a/datafusion/sqllogictest/test_files/nvl.slt
+++ b/datafusion/sqllogictest/test_files/nvl.slt
@@ -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
diff --git a/datafusion/sqllogictest/test_files/string/string_view.slt 
b/datafusion/sqllogictest/test_files/string/string_view.slt
index 2b44c86f52..12295a01a9 100644
--- a/datafusion/sqllogictest/test_files/string/string_view.slt
+++ b/datafusion/sqllogictest/test_files/string/string_view.slt
@@ -935,6 +935,14 @@ 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 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 TT
 EXPLAIN SELECT


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to