Jefffrey commented on code in PR #11502:
URL: https://github.com/apache/arrow-rs/pull/11502#discussion_r4301982880
##########
arrow-cast/src/cast/dictionary.rs:
##########
@@ -199,6 +206,58 @@ fn dictionary_to_dictionary_cast<K:
ArrowDictionaryKeyType>(
Ok(new_array)
}
+fn finish_keys_only<K2: ArrowDictionaryKeyType>(
+ cast_keys: ArrayRef,
+ values: ArrayRef,
+) -> Result<ArrayRef, ArrowError> {
+ let new_keys = cast_keys
+ .as_any()
+ .downcast_ref::<PrimitiveArray<K2>>()
+ .ok_or_else(|| {
+ ArrowError::ComputeError(
+ "Internal Error: cast keys did not downcast to target key
type".to_string(),
+ )
+ })?
+ .clone();
+ // SAFETY: caller rejects overflowing keys, so every non-null key stays in
bounds of `values`.
+ Ok(Arc::new(unsafe {
+ DictionaryArray::<K2>::new_unchecked(new_keys, values)
+ }))
+}
+
+fn cast_keys_only<K: ArrowDictionaryKeyType>(
+ array: &DictionaryArray<K>,
+ to_index_type: &DataType,
+ cast_options: &CastOptions,
+) -> Result<ArrayRef, ArrowError> {
+ let source_keys: ArrayRef =
Arc::new(PrimitiveArray::<K>::from(array.keys().to_data()));
Review Comment:
```suggestion
let source_keys = array.keys();
```
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]