You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "ethan-tyler (via GitHub)" <gi...@apache.org> on 2026/01/19 02:28:34 UTC
[I] [arrow-cast] can_cast_types allows Dictionary(_, Utf8View/BinaryView) but cast fails [arrow-rs]
ethan-tyler opened a new issue, #9219:
URL: https://github.com/apache/arrow-rs/issues/9219
**Describe the bug**
Casting to Dictionary(_, Utf8View) or Dictionary(_, BinaryView) fails:
`Cast error: Unsupported output type for dictionary packing: Utf8View`
can_cast_types returns true for these combinations, so this is a runtime inconsistency.
<!--
A clear and concise description of what the bug is.
-->
**To Reproduce**
```
use arrow_array::{BinaryArray, StringArray};
use arrow_cast::{can_cast_types, cast};
use arrow_schema::DataType;
fn main() {
// Utf8View
let arr = StringArray::from(vec![Some("a"), Some("b"), Some("a")]);
let target = DataType::Dictionary(Box::new(DataType::Int32), Box::new(DataType::Utf8View));
assert!(can_cast_types(arr.data_type(), &target)); // true
assert!(cast(&arr, &target).is_err()); // fails
// BinaryView
let bin = BinaryArray::from(vec![Some(b"a".as_slice()), Some(b"b"), Some(b"a")]);
let target = DataType::Dictionary(Box::new(DataType::Int32), Box::new(DataType::BinaryView));
assert!(can_cast_types(bin.data_type(), &target)); // true
assert!(cast(&bin, &target).is_err()); // fails
}
```
<!--
Steps to reproduce the behavior:
-->
**Expected behavior**
Cast succeeds, or can_cast_types returns false. Currently it claims true then returns Err at runtime.
<!--
A clear and concise description of what you expected to happen.
-->
**Use case**
DataFusion dictionary encodes partition columns for memory efficiency, and some pipelines require view types for schema alignment (schema_force_view_types). Currently no way to get Dictionary(K, Utf8View).
This isn't redundant with plain view arrays: views store 16 bytes per row (the u128 view struct), while dictionary keys are 1-4 bytes. For partition columns (constant per file), dictionary encoding can cut memory ~4-8x while still satisfying view-typed schema requirements.
**Additional context**
Related to #7114, but that was about implicit coercion. This is explicit casting and a can_cast_types consistency bug.
<!--
Add any other context about the problem here.
-->
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [arrow-cast] can_cast_types allows Dictionary(_, Utf8View/BinaryView) but cast fails [arrow-rs]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb closed issue #9219: [arrow-cast] can_cast_types allows Dictionary(_, Utf8View/BinaryView) but cast fails
URL: https://github.com/apache/arrow-rs/issues/9219
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [arrow-cast] can_cast_types allows Dictionary(_, Utf8View/BinaryView) but cast fails [arrow-rs]
Posted by "ethan-tyler (via GitHub)" <gi...@apache.org>.
ethan-tyler commented on issue #9219:
URL: https://github.com/apache/arrow-rs/issues/9219#issuecomment-3766125549
take
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org