(
batch1: &RecordBatch,
batch2: &RecordBatch,
agg1: Arc<AggregateUDF>,
agg2: Arc<AggregateUDF>,
schema: &Schema,
)
| 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 | } |
searching dependent graphs…