Skip to content

Commit 6b56441

Browse files
committed
remove general conversion
Signed-off-by: jayzhan211 <jayzhan211@gmail.com>
1 parent 7f6e6e7 commit 6b56441

2 files changed

Lines changed: 11 additions & 40 deletions

File tree

datafusion/common/src/scalar.rs

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -2110,43 +2110,6 @@ impl ScalarValue {
21102110
}
21112111
}
21122112

2113-
/// Retrieve ScalarValue for each row in `array`
2114-
///
2115-
/// Example
2116-
/// ```
2117-
/// use datafusion_common::ScalarValue;
2118-
/// use arrow::array::ListArray;
2119-
/// use arrow::datatypes::{DataType, Int32Type};
2120-
///
2121-
/// let list_arr = ListArray::from_iter_primitive::<Int32Type, _, _>(vec![
2122-
/// Some(vec![Some(1), Some(2), Some(3)]),
2123-
/// None,
2124-
/// Some(vec![Some(4), Some(5)])
2125-
/// ]);
2126-
///
2127-
/// let scalar_vec = ScalarValue::convert_array_to_scalar_vec(&list_arr).unwrap();
2128-
///
2129-
/// let expected = vec![
2130-
/// vec![
2131-
/// ScalarValue::Int32(Some(1)),
2132-
/// ScalarValue::Int32(Some(2)),
2133-
/// ScalarValue::Int32(Some(3)),
2134-
/// ],
2135-
/// vec![],
2136-
/// vec![ScalarValue::Int32(Some(4)), ScalarValue::Int32(Some(5))]
2137-
/// ];
2138-
///
2139-
/// assert_eq!(scalar_vec, expected);
2140-
/// ```
2141-
pub fn convert_array_to_scalar_vec(array: &dyn Array) -> Result<Vec<Vec<Self>>> {
2142-
let data_type = array.data_type().to_owned();
2143-
2144-
match data_type {
2145-
DataType::List(_) => Self::convert_list_array_to_scalar_vec(array),
2146-
_ => Ok(vec![Self::convert_non_list_array_to_scalars(array)?]),
2147-
}
2148-
}
2149-
21502113
// TODO: Support more types after other ScalarValue is wrapped with ArrayRef
21512114
/// Get raw data (inner array) inside ScalarValue
21522115
pub fn raw_data(&self) -> Result<ArrayRef> {

datafusion/physical-expr/src/aggregate/array_agg_distinct.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,17 @@ impl Accumulator for DistinctArrayAggAccumulator {
137137
assert_eq!(values.len(), 1, "batch input should only include 1 column!");
138138

139139
let array = &values[0];
140-
let scalars = ScalarValue::convert_array_to_scalar_vec(array)?;
141-
for scalar in scalars {
142-
self.values.extend(scalar)
140+
match array.data_type() {
141+
DataType::List(_) => {
142+
let scalar_vec = ScalarValue::convert_list_array_to_scalar_vec(array)?;
143+
for scalars in scalar_vec {
144+
self.values.extend(scalars);
145+
}
146+
}
147+
_ => {
148+
let scalars = ScalarValue::convert_non_list_array_to_scalars(array)?;
149+
self.values.extend(scalars);
150+
}
143151
}
144152
Ok(())
145153
}

0 commit comments

Comments
 (0)