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 28856e15bd Fallback to Utf8View for `Dict(_, Utf8View)` in 
`type_union_resolution_coercion` (#14602)
28856e15bd is described below

commit 28856e15bd490044d24619e19057160e647aa256
Author: Jay Zhan <[email protected]>
AuthorDate: Thu Feb 13 18:58:54 2025 +0800

    Fallback to Utf8View for `Dict(_, Utf8View)` in 
`type_union_resolution_coercion` (#14602)
    
    * utf8view fix
    
    * fmt
    
    * add more view type
    
    * fmt
    
    * add test and remove coercion that has no test
    
    * fix
---
 datafusion/expr-common/src/type_coercion/binary.rs | 13 +++++++++++--
 datafusion/sqllogictest/test_files/coalesce.slt    |  5 +++++
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/datafusion/expr-common/src/type_coercion/binary.rs 
b/datafusion/expr-common/src/type_coercion/binary.rs
index 3be35490a4..64c26192ae 100644
--- a/datafusion/expr-common/src/type_coercion/binary.rs
+++ b/datafusion/expr-common/src/type_coercion/binary.rs
@@ -537,8 +537,16 @@ fn type_union_resolution_coercion(
         }
         (DataType::Dictionary(index_type, value_type), other_type)
         | (other_type, DataType::Dictionary(index_type, value_type)) => {
-            let new_value_type = type_union_resolution_coercion(value_type, 
other_type);
-            new_value_type.map(|t| DataType::Dictionary(index_type.clone(), 
Box::new(t)))
+            match type_union_resolution_coercion(value_type, other_type) {
+                // Dict with View type is redundant, use value type instead
+                // TODO: Add binary view, list view with tests
+                Some(DataType::Utf8View) => Some(DataType::Utf8View),
+                Some(new_value_type) => Some(DataType::Dictionary(
+                    index_type.clone(),
+                    Box::new(new_value_type),
+                )),
+                None => None,
+            }
         }
         (DataType::Struct(lhs), DataType::Struct(rhs)) => {
             if lhs.len() != rhs.len() {
@@ -589,6 +597,7 @@ fn type_union_resolution_coercion(
                 .or_else(|| temporal_coercion_nonstrict_timezone(lhs_type, 
rhs_type))
                 .or_else(|| string_coercion(lhs_type, rhs_type))
                 .or_else(|| numeric_string_coercion(lhs_type, rhs_type))
+                .or_else(|| binary_coercion(lhs_type, rhs_type))
         }
     }
 }
diff --git a/datafusion/sqllogictest/test_files/coalesce.slt 
b/datafusion/sqllogictest/test_files/coalesce.slt
index a624d1def9..5f2d2f0d1d 100644
--- a/datafusion/sqllogictest/test_files/coalesce.slt
+++ b/datafusion/sqllogictest/test_files/coalesce.slt
@@ -438,3 +438,8 @@ Date32
 
 statement ok
 drop table test
+
+query T
+select coalesce(arrow_cast('', 'Utf8View'), arrow_cast('', 'Dictionary(UInt32, 
Utf8)'));
+----
+(empty)
\ No newline at end of file


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

Reply via email to