timsaucer commented on code in PR #12520:
URL: https://github.com/apache/datafusion/pull/12520#discussion_r1765065036


##########
datafusion/core/src/dataframe/mod.rs:
##########
@@ -1889,6 +1913,28 @@ mod tests {
         Ok(())
     }
 
+    #[tokio::test]
+    async fn select_exprs() -> Result<()> {
+        // build plan using Table API
+        let t = test_table().await?;
+        let t2 = t.select_exprs(&["c1", "c2", "c11", "c2 * c11"])?;
+
+        // looks like alias does not work
+        // let t2 = t.select_expr(&["c1", "c2", "c11", "c11 as r"])?;
+        let plan = t2.plan.clone();
+
+        // let sql_plan =
+        //     create_plan("SELECT c1, c2, c11, r FROM 
aggregate_test_100").await?;
+        // build query using SQL
+        let sql_plan =
+            create_plan("SELECT c1, c2, c11, c2 * c11 FROM 
aggregate_test_100").await?;
+
+        // the two plans should be identical
+        assert_same_plan(&plan, &sql_plan);

Review Comment:
   A slightly better unit test might be to test the plan created using 
`select_exprs` against the dataframe api approach rather than `create_plan`.
   
   Pseudocode since I'm not at a point right now where I could test it directly:
   
   ```
   let t3 = t.select(&[col("c1"), col("c2"), col("c11"), col("c2") * 
col("c11")]);
   let expected_plan = t3.plan;
   ```



-- 
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: github-unsubscr...@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org
For additional commands, e-mail: github-h...@datafusion.apache.org

Reply via email to