alamb commented on code in PR #8341:
URL: https://github.com/apache/arrow-datafusion/pull/8341#discussion_r1408229193


##########
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:
   You are right -- I mistakenly assumed that the `scan_empty` was returning a 
DataFrame (it is actually returning a `LogicalPlanBuilder`): 
https://github.com/alamb/arrow-datafusion/blob/9a15bf89682728a277cc0a8f443fbd4ba8398ae6/datafusion/core/src/test_util/mod.rs#L133
   
   I will see if I can find a better home for this



-- 
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]

Reply via email to