diff --git a/arrow/src/array/array_dictionary.rs b/arrow/src/array/array_dictionary.rs index 5948658157ee..9b036da7ae5d 100644 --- a/arrow/src/array/array_dictionary.rs +++ b/arrow/src/array/array_dictionary.rs @@ -101,9 +101,9 @@ impl<'a, K: ArrowPrimitiveType> DictionaryArray { .flatten() } - /// Returns an `ArrayRef` to the dictionary values. - pub fn values(&self) -> ArrayRef { - self.values.clone() + /// Returns a reference to the dictionary values array + pub fn values(&self) -> &ArrayRef { + &self.values } /// Returns a clone of the value type of this list. diff --git a/arrow/src/compute/kernels/cast.rs b/arrow/src/compute/kernels/cast.rs index de1516b0768b..4c5bb93ac99c 100644 --- a/arrow/src/compute/kernels/cast.rs +++ b/arrow/src/compute/kernels/cast.rs @@ -1371,10 +1371,10 @@ fn dictionary_cast( })?; let keys_array: ArrayRef = Arc::new(dict_array.keys_array()); - let values_array: ArrayRef = dict_array.values(); + let values_array = dict_array.values(); let cast_keys = cast_with_options(&keys_array, to_index_type, &cast_options)?; let cast_values = - cast_with_options(&values_array, to_value_type, &cast_options)?; + cast_with_options(values_array, to_value_type, &cast_options)?; // Failure to cast keys (because they don't fit in the // target type) results in NULL values; diff --git a/arrow/src/compute/kernels/sort.rs b/arrow/src/compute/kernels/sort.rs index 7cd463d6ebb9..0a02167dc528 100644 --- a/arrow/src/compute/kernels/sort.rs +++ b/arrow/src/compute/kernels/sort.rs @@ -1007,7 +1007,7 @@ mod tests { expected_data: Vec>, ) { let array = DictionaryArray::::from_iter(data.into_iter()); - let array_values = array.values(); + let array_values = array.values().clone(); let dict = array_values .as_any() .downcast_ref::()