viirya commented on code in PR #8341:
URL: https://github.com/apache/arrow-datafusion/pull/8341#discussion_r1408227214
##########
datafusion/core/tests/dataframe/mod.rs:
##########
@@ -1597,3 +1597,28 @@ async fn test_array_agg() -> Result<()> {
Ok(())
}
+
+#[tokio::test]
+async fn aggregate_with_alias() -> Result<()> {
+ let ctx = SessionContext::new();
+ let state = ctx.state();
+
+ let schema = Arc::new(Schema::new(vec![
+ Field::new("c1", DataType::Utf8, false),
+ Field::new("c2", DataType::UInt32, false),
+ ]));
+
+ let plan = scan_empty(None, schema.as_ref(), None)?
+ .aggregate(vec![col("c1")], vec![sum(col("c2"))])?
+ .project(vec![col("c1"), sum(col("c2")).alias("total_salary")])?
+ .build()?;
+
+ let plan = state.optimize(&plan)?;
+ let physical_plan = state.create_physical_plan(&Arc::new(plan)).await?;
+ assert_eq!("c1", physical_plan.schema().field(0).name().as_str());
+ assert_eq!(
+ "total_salary",
+ physical_plan.schema().field(1).name().as_str()
Review Comment:
Actually this test doesn't really use DataFrame API but creates logical plan
and physical plan with `SessionState`. Maybe `physical-plan`? But there doesn't
have `tests` module, so here is also good.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]