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

Function evaluate_agg_test

datafusion/core/tests/expr_api/mod.rs:369–389  ·  view source on GitHub ↗

Evaluates the specified expr as an aggregate and compares the result to the expected result.

(expr: Expr, expected_lines: Vec<&str>)

Source from the content-addressed store, hash-verified

367/// Evaluates the specified expr as an aggregate and compares the result to the
368/// expected result.
369async fn evaluate_agg_test(expr: Expr, expected_lines: Vec<&str>) {
370 let ctx = SessionContext::new();
371 let group_expr = vec![];
372 let agg_expr = vec![expr];
373 let result = ctx
374 .read_batch(TEST_BATCH.clone())
375 .unwrap()
376 .aggregate(group_expr, agg_expr)
377 .unwrap()
378 .collect()
379 .await
380 .unwrap();
381
382 let result = pretty_format_batches(&result).unwrap().to_string();
383 let actual_lines = result.lines().collect::<Vec<_>>();
384
385 assert_eq!(
386 expected_lines, actual_lines,
387 "\n\nexpected:\n\n{expected_lines:#?}\nactual:\n\n{actual_lines:#?}\n\n"
388 );
389}
390
391/// Converts the `Expr` to a `PhysicalExpr`, evaluates it against the provided
392/// `RecordBatch` and compares the result to the expected result.

Calls 6

newFunction · 0.85
collectMethod · 0.80
read_batchMethod · 0.80
aggregateMethod · 0.45
cloneMethod · 0.45
to_stringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…