From 7699ff089ee9d59c3264f236c718cede3104928f Mon Sep 17 00:00:00 2001 From: DouPache Date: Fri, 27 Sep 2024 11:27:32 +0800 Subject: [PATCH] add binary to string_view coercion --- .../expr-common/src/type_coercion/binary.rs | 4 ++++ .../sqllogictest/test_files/binary_view.slt | 15 +++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/datafusion/expr-common/src/type_coercion/binary.rs b/datafusion/expr-common/src/type_coercion/binary.rs index c1e96a8fa97d..e66a9ae1ea98 100644 --- a/datafusion/expr-common/src/type_coercion/binary.rs +++ b/datafusion/expr-common/src/type_coercion/binary.rs @@ -1052,12 +1052,16 @@ fn binary_to_string_coercion( match (lhs_type, rhs_type) { (Binary, Utf8) => Some(Utf8), (Binary, LargeUtf8) => Some(LargeUtf8), + (BinaryView, Utf8) => Some(Utf8View), + (BinaryView, LargeUtf8) => Some(LargeUtf8), (LargeBinary, Utf8) => Some(LargeUtf8), (LargeBinary, LargeUtf8) => Some(LargeUtf8), (Utf8, Binary) => Some(Utf8), (Utf8, LargeBinary) => Some(LargeUtf8), + (Utf8, BinaryView) => Some(Utf8View), (LargeUtf8, Binary) => Some(LargeUtf8), (LargeUtf8, LargeBinary) => Some(LargeUtf8), + (LargeUtf8, BinaryView) => Some(LargeUtf8), _ => None, } } diff --git a/datafusion/sqllogictest/test_files/binary_view.slt b/datafusion/sqllogictest/test_files/binary_view.slt index 77ec77c5ecce..f973b909aeb6 100644 --- a/datafusion/sqllogictest/test_files/binary_view.slt +++ b/datafusion/sqllogictest/test_files/binary_view.slt @@ -200,3 +200,18 @@ NULL R NULL NULL NULL NULL statement ok drop table test; + +statement ok +create table bv as values +( + arrow_cast('one', 'BinaryView'), + arrow_cast('two', 'BinaryView') +); + +query B +select column1 like 'o%' from bv; +---- +true + +statement ok +drop table bv;