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 17:55:28 UTC

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

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


##########
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:
   Maybe we could also add a test here that had two unaliased subqueries (should result in a cross join) as a potential other case that would be good to cover



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