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/04/29 17:48:05 UTC

[GitHub] [arrow-datafusion] alamb commented on a diff in pull request #2373: Fix bugs with CTE aliasing and normalize all identifiers in the SQL planner

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


##########
datafusion/core/tests/sql/select.rs:
##########
@@ -830,6 +830,29 @@ async fn query_on_string_dictionary() -> Result<()> {
     Ok(())
 }
 
+#[tokio::test]
+async fn query_cte_with_alias() -> Result<()> {
+    let ctx = SessionContext::new();
+    let schema = Schema::new(vec![
+        Field::new("id", DataType::Int16, false),
+        Field::new("a", DataType::Int16, false),
+    ]);
+    let empty_table = Arc::new(EmptyTable::new(Arc::new(schema)));
+    ctx.register_table("t1", empty_table)?;
+    let sql = "WITH \
+        v1 AS (SELECT * FROM t1), \
+        v2 AS (SELECT v1.id AS id, v1a.id AS id_a, v1b.id AS id_b \
+        FROM v1, v1 v1a, v1 v1b \

Review Comment:
   so many `v`s!



##########
datafusion/core/src/catalog/mod.rs:
##########
@@ -132,30 +129,3 @@ impl<'a> From<ResolvedTableReference<'a>> for TableReference<'a> {
         }
     }
 }
-
-impl<'a> TryFrom<&'a sqlparser::ast::ObjectName> for TableReference<'a> {

Review Comment:
   cc @returnString 



##########
datafusion/core/tests/sql/information_schema.rs:
##########
@@ -307,14 +307,8 @@ async fn information_schema_show_columns() {
     let result = plan_and_collect(&ctx, "SHOW columns from t").await.unwrap();
     assert_batches_sorted_eq!(expected, &result);
 
-    // This isn't ideal but it is consistent behavior for `SELECT * from T`
-    let err = plan_and_collect(&ctx, "SHOW columns from T")

Review Comment:
   Maybe this change would remain more faithful to the original test's stated intent (aka use `"T"` to not normalize the table?
   
   ```sql
       let err = plan_and_collect(&ctx, "SHOW columns from \"T\"")
   ```



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