rich-t-kid-datadog commented on code in PR #7713:
URL: https://github.com/apache/arrow-rs/pull/7713#discussion_r2162006795
##########
arrow-cast/src/cast/run_array.rs:
##########
@@ -0,0 +1,152 @@
+use crate::cast::*;
+
+pub(crate) fn run_end_encoded_cast<K: RunEndIndexType>(
+ array: &dyn Array,
+ to_type: &DataType,
+ cast_options: &CastOptions,
+) -> Result<ArrayRef, ArrowError> {
+ match array.data_type() {
+ DataType::RunEndEncoded(_run_end_field, _values_field) => {
+ let run_array = array
+ .as_any()
+ .downcast_ref::<RunArray<K>>()
+ .ok_or_else(|| ArrowError::CastError("Expected
RunArray".to_string()))?;
+
+ let values = run_array.values();
+
+ match to_type {
+ // CASE 1: Stay as RunEndEncoded, cast only the values
+ DataType::RunEndEncoded(_target_run_end_field,
target_value_field) => {
Review Comment:
For example
`run_ends: [1000, 50000, 80000, 1000000] // type: Int64
`
`let casted_run_ends: Vec<i16> = int64_run_ends.iter().map(|&x| x as
i16).collect();`
This would result in
`Original: [1000, 50000, 80000, 1000000]
`
`Casted (as i16): [1000, -15536, 14464, -31072]`
Which wouldnt be a valid run_end array. I dont think we should allow clients
to do this. a solution could be to only allow upcast to higher bit Ints
--
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]