You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datafusion.apache.org by gi...@apache.org on 2026/04/24 08:30:35 UTC
(datafusion) 01/01: Fix: allow coercion from Binary and LargeBinary into BinaryView (#21800)
This is an automated email from the ASF dual-hosted git repository.
github-merge-queue[bot] pushed a commit to branch gh-readonly-queue/main/pr-21800-14c18ece4a17ab6da2259c8a339993a0ff35a4f1
in repository https://gitbox.apache.org/repos/asf/datafusion.git
commit cc67c13e167e5dfa2b444f18c1c06ea17f6e3c0d
Author: Bert Vermeiren <10...@users.noreply.github.com>
AuthorDate: Fri Apr 24 10:30:11 2026 +0200
Fix: allow coercion from Binary and LargeBinary into BinaryView (#21800)
## Which issue does this PR close?
- Closes #21798
## Rationale for this change
The coercion should take place in the same way as is foreseen already
for the string datatypes (Utf8, LargeUtf8, Null -> Utf8View)
## What changes are included in this PR?
The coerced_from function in
datafusion/expr/src/type_coercion/functions.rs was missing a match arm
for (BinaryView, Binary | LargeBinary | Null).
## Are these changes tested?
Additional unit test written : `test_binary_conversion`
## Are there any user-facing changes?
No
Co-authored-by: Bert Vermeiren <be...@datadobi.com>
---
datafusion/expr/src/type_coercion/functions.rs | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/datafusion/expr/src/type_coercion/functions.rs b/datafusion/expr/src/type_coercion/functions.rs
index 654e790667..7b6cb7b35d 100644
--- a/datafusion/expr/src/type_coercion/functions.rs
+++ b/datafusion/expr/src/type_coercion/functions.rs
@@ -888,6 +888,8 @@ fn coerced_from<'a>(
(Utf8View, Utf8 | LargeUtf8 | Null) => Some(type_into.clone()),
// Any type can be coerced into strings
(Utf8 | LargeUtf8, _) => Some(type_into.clone()),
+ // We can go into a BinaryView from a Binary or LargeBinary
+ (BinaryView, Binary | LargeBinary | Null) => Some(type_into.clone()),
(Null, _) if can_cast_types(type_from, type_into) => Some(type_into.clone()),
(List(_), FixedSizeList(_, _)) => Some(type_into.clone()),
@@ -956,6 +958,20 @@ mod tests {
let cases = vec![
(DataType::Utf8View, DataType::Utf8),
(DataType::Utf8View, DataType::LargeUtf8),
+ (DataType::Utf8View, DataType::Null),
+ ];
+
+ for case in cases {
+ assert_eq!(coerced_from(&case.0, &case.1), Some(case.0));
+ }
+ }
+
+ #[test]
+ fn test_binary_conversion() {
+ let cases = vec![
+ (DataType::BinaryView, DataType::Binary),
+ (DataType::BinaryView, DataType::LargeBinary),
+ (DataType::BinaryView, DataType::Null),
];
for case in cases {
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datafusion.apache.org
For additional commands, e-mail: commits-help@datafusion.apache.org