| 179 | } |
| 180 | |
| 181 | fn accumulator(&self, acc_args: AccumulatorArgs) -> Result<Box<dyn Accumulator>> { |
| 182 | let delimiter = Self::extract_delimiter(&acc_args)?; |
| 183 | |
| 184 | if !acc_args.is_distinct && acc_args.order_bys.is_empty() { |
| 185 | Ok(Box::new(SimpleStringAggAccumulator::new(&delimiter))) |
| 186 | } else { |
| 187 | let array_agg_acc = self.array_agg.accumulator(AccumulatorArgs { |
| 188 | return_field: Field::new( |
| 189 | "f", |
| 190 | DataType::new_list(acc_args.return_field.data_type().clone(), true), |
| 191 | true, |
| 192 | ) |
| 193 | .into(), |
| 194 | exprs: &filter_index(acc_args.exprs, 1), |
| 195 | expr_fields: &filter_index(acc_args.expr_fields, 1), |
| 196 | // Unchanged below; we list each field explicitly in case we ever add more |
| 197 | // fields to AccumulatorArgs making it easier to see if changes are also |
| 198 | // needed here. |
| 199 | schema: acc_args.schema, |
| 200 | ignore_nulls: acc_args.ignore_nulls, |
| 201 | order_bys: acc_args.order_bys, |
| 202 | is_reversed: acc_args.is_reversed, |
| 203 | name: acc_args.name, |
| 204 | is_distinct: acc_args.is_distinct, |
| 205 | })?; |
| 206 | |
| 207 | Ok(Box::new(StringAggAccumulator::new( |
| 208 | array_agg_acc, |
| 209 | &delimiter, |
| 210 | ))) |
| 211 | } |
| 212 | } |
| 213 | |
| 214 | fn reverse_expr(&self) -> datafusion_expr::ReversedUDAF { |
| 215 | datafusion_expr::ReversedUDAF::Reversed(string_agg_udaf()) |