Repository navigation
Description
What is the problem the feature request solves?
arrow-rs adds Array::to_arc in apache/arrow-rs#12420, and it is expected to ship in arrow 60.3.0 or 61.0.0. It returns an ArrayRef that shares the buffers of a &dyn Array. When the &dyn Array is an &ArrayRef, it returns a new reference to the same allocation.
Comet turns a &dyn Array into an ArrayRef with a workaround in two places:
make_array(array.to_data())inunpack_dictionary, for inputs that aren't dictionary encoded:datafusion-comet/native/spark-expr/src/kernels/temporal.rs
Lines 1253 to 1259 in f141d90
fn unpack_dictionary(array: &dyn Array) -> Result<ArrayRef, SparkError> { match array.data_type() { DataType::Dictionary(_, value_type) => arrow::compute::cast(array, value_type) .map_err(|error| SparkError::Internal(error.to_string())), _ => Ok(make_array(array.to_data())), } } input.slice(0, input.len())in theextrematest helper:fn extrema(input: &dyn Array, is_min: bool) -> ArrayRef { let ColumnarValue::Array(result) = invoke(ColumnarValue::Array(input.slice(0, input.len())), is_min)
make_array(x.to_data()) builds an ArrayData and then rebuilds a typed array from it. slice(0, len) recounts the null buffer's nulls. to_arc clones an arrow-rs array into a new Arc, and for an ArrayRef it only increments the reference count.
Describe the potential solution
After Comet upgrades to an arrow release that includes Array::to_arc, replace both workarounds with x.to_arc(). Comet's native/Cargo.toml depends on arrow 59.2.0 today, so this waits for that upgrade.
Additional context
The same arrow-rs PR switches arrow's own cast, concat, nullif, and shift from these workarounds to to_arc.
Activity