MCPcopy Create free account
hub / github.com/apache/datafusion / merge_batch

Method merge_batch

datafusion/functions-aggregate/src/array_agg.rs:369–394  ·  view source on GitHub ↗
(&mut self, states: &[ArrayRef])

Source from the content-addressed store, hash-verified

367 }
368
369 fn merge_batch(&mut self, states: &[ArrayRef]) -> Result<()> {
370 // Append value like ListArray(Int64Array(1,2,3), Int64Array(4,5,6))
371 if states.is_empty() {
372 return Ok(());
373 }
374
375 assert_eq_or_internal_err!(states.len(), 1, "expects single state");
376
377 let list_arr = as_list_array(&states[0])?;
378
379 match Self::get_optional_values_to_merge_as_is(list_arr) {
380 Some(values) => {
381 // Make sure we don't insert empty lists
382 if !values.is_empty() {
383 self.values.push_back(values);
384 }
385 }
386 None => {
387 for arr in list_arr.iter().flatten() {
388 self.values.push_back(arr);
389 }
390 }
391 }
392
393 Ok(())
394 }
395
396 fn state(&mut self) -> Result<Vec<ScalarValue>> {
397 Ok(vec![self.evaluate()?])

Calls 15

as_list_arrayFunction · 0.85
newFunction · 0.85
take_function_argsFunction · 0.85
merge_ordered_arraysFunction · 0.85
flattenMethod · 0.80
offsetsMethod · 0.80
columnsMethod · 0.80
is_emptyMethod · 0.45
iterMethod · 0.45
maxMethod · 0.45
valuesMethod · 0.45
is_nullMethod · 0.45