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

Function test_aggregate_subexpr

datafusion/core/tests/dataframe/mod.rs:1091–1125  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1089
1090#[tokio::test]
1091async fn test_aggregate_subexpr() -> Result<()> {
1092 let df = test_table().await?;
1093
1094 let group_expr = col("c2") + lit(1);
1095 let aggr_expr = sum(col("c3") + lit(2));
1096
1097 let df = df
1098 // GROUP BY `c2 + 1`
1099 .aggregate(vec![group_expr.clone()], vec![aggr_expr.clone()])?
1100 // SELECT `c2 + 1` as c2 + 10, sum(c3 + 2) + 20
1101 // SELECT expressions contain aggr_expr and group_expr as subexpressions
1102 .select(vec![
1103 group_expr.alias("c2") + lit(10),
1104 (aggr_expr + lit(20)).alias("sum"),
1105 ])?;
1106
1107 let df_results = df.collect().await?;
1108
1109 assert_snapshot!(
1110 batches_to_sort_string(&df_results),
1111 @r"
1112 +----------------+------+
1113 | c2 + Int32(10) | sum |
1114 +----------------+------+
1115 | 12 | 431 |
1116 | 13 | 248 |
1117 | 14 | 453 |
1118 | 15 | 95 |
1119 | 16 | -146 |
1120 +----------------+------+
1121 "
1122 );
1123
1124 Ok(())
1125}
1126
1127#[tokio::test]
1128async fn test_aggregate_name_collision() -> Result<()> {

Callers

nothing calls this directly

Calls 7

test_tableFunction · 0.85
sumFunction · 0.85
collectMethod · 0.80
colFunction · 0.50
litFunction · 0.50
selectMethod · 0.45
aggregateMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…