alamb commented on code in PR #4582:
URL: https://github.com/apache/arrow-datafusion/pull/4582#discussion_r1048350498
##########
datafusion/physical-expr/src/aggregate/utils.rs:
##########
@@ -21,28 +21,13 @@ use arrow::array::ArrayRef;
use datafusion_common::{Result, ScalarValue};
use datafusion_expr::Accumulator;
-/// Extract scalar values from an accumulator. This can return an error if the
accumulator
-/// has any non-scalar values.
-pub fn get_accum_scalar_values(accum: &dyn Accumulator) ->
Result<Vec<ScalarValue>> {
- accum
- .state()?
- .iter()
- .map(|agg| agg.as_scalar().map(|v| v.clone()))
- .collect::<Result<Vec<_>>>()
-}
-
-/// Convert scalar values from an accumulator into arrays. This can return an
error if the
-/// accumulator has any non-scalar values.
+/// Convert scalar values from an accumulator into arrays.
pub fn get_accum_scalar_values_as_arrays(
accum: &dyn Accumulator,
) -> Result<Vec<ArrayRef>> {
accum
.state()?
.iter()
- .map(|v| {
- v.as_scalar()
- .map(|s| vec![s.clone()])
- .and_then(ScalarValue::iter_to_array)
- })
+ .map(|s| ScalarValue::iter_to_array(vec![s.clone()]))
Review Comment:
Good call -- changed to
```rust
.map(|s| s.to_array_of_size(1))
```
in commit 1165cffe7
--
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]