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

Function merge

datafusion/functions-aggregate/src/stddev.rs:400–454  ·  view source on GitHub ↗
(
        batch1: &RecordBatch,
        batch2: &RecordBatch,
        agg1: Arc<AggregateUDF>,
        agg2: Arc<AggregateUDF>,
        schema: &Schema,
    )

Source from the content-addressed store, hash-verified

398 }
399
400 fn merge(
401 batch1: &RecordBatch,
402 batch2: &RecordBatch,
403 agg1: Arc<AggregateUDF>,
404 agg2: Arc<AggregateUDF>,
405 schema: &Schema,
406 ) -> Result<ScalarValue> {
407 let expr = col("a", schema)?;
408 let expr_field = expr.return_field(schema)?;
409
410 let args1 = AccumulatorArgs {
411 return_field: Field::new("f", DataType::Float64, true).into(),
412 schema,
413 expr_fields: &[Arc::clone(&expr_field)],
414 ignore_nulls: false,
415 order_bys: &[],
416 name: "a",
417 is_distinct: false,
418 is_reversed: false,
419 exprs: &[Arc::clone(&expr)],
420 };
421
422 let args2 = AccumulatorArgs {
423 return_field: Field::new("f", DataType::Float64, true).into(),
424 schema,
425 expr_fields: &[expr_field],
426 ignore_nulls: false,
427 order_bys: &[],
428 name: "a",
429 is_distinct: false,
430 is_reversed: false,
431 exprs: &[expr],
432 };
433
434 let mut accum1 = agg1.accumulator(args1)?;
435 let mut accum2 = agg2.accumulator(args2)?;
436
437 let value1 = vec![
438 col("a", schema)?
439 .evaluate(batch1)
440 .and_then(|v| v.into_array(batch1.num_rows()))?,
441 ];
442 let value2 = vec![
443 col("a", schema)?
444 .evaluate(batch2)
445 .and_then(|v| v.into_array(batch2.num_rows()))?,
446 ];
447
448 accum1.update_batch(&value1)?;
449 accum2.update_batch(&value2)?;
450 let state2 = get_accum_scalar_values_as_arrays(accum2.as_mut())?;
451 accum1.merge_batch(&state2)?;
452 let result = accum1.evaluate()?;
453 Ok(result)
454 }
455}

Callers 2

stddev_f64_merge_1Function · 0.70
stddev_f64_merge_2Function · 0.70

Calls 9

newFunction · 0.85
colFunction · 0.50
return_fieldMethod · 0.45
intoMethod · 0.45
accumulatorMethod · 0.45
update_batchMethod · 0.45
merge_batchMethod · 0.45
evaluateMethod · 0.45

Tested by 2

stddev_f64_merge_1Function · 0.56
stddev_f64_merge_2Function · 0.56

Used in the wild real call sites across dependent graphs

searching dependent graphs…