You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/05/02 19:46:34 UTC

[GitHub] [arrow-datafusion] andygrove commented on a diff in pull request #2418: Allow subqueries without aliases

andygrove commented on code in PR #2418:
URL: https://github.com/apache/arrow-datafusion/pull/2418#discussion_r863134045


##########
datafusion/core/tests/sql/select.rs:
##########
@@ -925,6 +925,38 @@ async fn csv_select_nested() -> Result<()> {
     Ok(())
 }
 
+#[tokio::test]
+async fn csv_select_nested_without_aliases() -> Result<()> {
+    let ctx = SessionContext::new();
+    register_aggregate_csv(&ctx).await?;
+    let sql = "SELECT o1, o2, c3
+               FROM (
+                 SELECT c1 AS o1, c2 + 1 AS o2, c3
+                 FROM (
+                   SELECT c1, c2, c3, c4
+                   FROM aggregate_test_100
+                   WHERE c1 = 'a' AND c2 >= 4
+                   ORDER BY c2 ASC, c3 ASC
+                 )
+               )";
+    let actual = execute_to_batches(&ctx, sql).await;
+    let expected = vec![
+        "+----+----+------+",
+        "| o1 | o2 | c3   |",
+        "+----+----+------+",
+        "| a  | 5  | -101 |",
+        "| a  | 5  | -54  |",
+        "| a  | 5  | -38  |",
+        "| a  | 5  | 65   |",
+        "| a  | 6  | -101 |",
+        "| a  | 6  | -31  |",
+        "| a  | 6  | 36   |",
+        "+----+----+------+",
+    ];
+    assert_batches_eq!(expected, &actual);
+    Ok(())
+}
+

Review Comment:
   Thanks for the review @alamb. I added the suggested test and did not run into problems so will go ahead and merge this one.



-- 
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-unsubscribe@arrow.apache.org

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