Apache DataFusion SQL Query Engine
feat: coerce from fixed size binary to binary view (#16110)
Chen Chongchence3e3874ec74
diff --git a/datafusion/expr-common/src/type_coercion/binary.rs b/datafusion/expr-common/src/type_coercion/binary.rsindex 9ab83dd0bf..d0fcda9733 100644--- a/datafusion/expr-common/src/type_coercion/binary.rs+++ b/datafusion/expr-common/src/type_coercion/binary.rs@@ -1303,6 +1303,9 @@ fn binary_coercion(lhs_type: &DataType, rhs_type: &DataType) -> Option<DataType>// Cast FixedSizeBinary to Binary(FixedSizeBinary(_), Binary) | (Binary, FixedSizeBinary(_)) => Some(Binary),+ (FixedSizeBinary(_), BinaryView) | (BinaryView, FixedSizeBinary(_)) => {+ Some(BinaryView)+ }_ => None,}diff --git a/datafusion/sqllogictest/test_files/binary.slt b/datafusion/sqllogictest/test_files/binary.sltindex 5ac13779ac..1077c32e46 100644--- a/datafusion/sqllogictest/test_files/binary.slt+++ b/datafusion/sqllogictest/test_files/binary.slt@@ -165,6 +165,15 @@ NULL NULLff0102 false000102 true+query ?B+SELECT arrow_cast(column1, 'FixedSizeBinary(3)'), arrow_cast(column1, 'FixedSizeBinary(3)') = arrow_cast(arrow_cast(X'000102', 'FixedSizeBinary(3)'), 'BinaryView') FROM t;+----+000102 true+003102 false+NULL NULL+ff0102 false+000102 true+# Plan should not have a cast of the column (should have casted the literal# to FixedSizeBinary as that is much faster)