Jefffrey commented on issue #6016:
URL: 
https://github.com/apache/arrow-datafusion/issues/6016#issuecomment-1509492914

   Looks to be due to the InlineTableScan analyzer rule, specifically:
   
   
https://github.com/apache/arrow-datafusion/blob/68bd113a74f045cd24d01418c92c83f2e3a18853/datafusion/optimizer/src/analyzer/inline_table_scan.rs#L56-L79
   
   Where it converts view into a subquery alias, using the `table_name` as the 
subquery alias:
   
   
https://github.com/apache/arrow-datafusion/blob/68bd113a74f045cd24d01418c92c83f2e3a18853/datafusion/optimizer/src/analyzer/inline_table_scan.rs#L76
   
   But doesn't rewrite the parent projection to use this correct subquery alias.
   
   So given input plan:
   
   ```
   Projection: cat.sch.v.c1, cat.sch.v.c2, cat.sch.v.c3
     TableScan: cat.sch.v
   ```
   
   After the rule this becomes:
   
   ```
   Projection: cat.sch.v.c1, cat.sch.v.c2, cat.sch.v.c3
     SubqueryAlias: cat.sch.v
       Projection: aggregate_test_100.c1, aggregate_test_100.c2, 
aggregate_test_100.c3
         Projection: aggregate_test_100.c1, aggregate_test_100.c2, 
aggregate_test_100.c3
           TableScan: aggregate_test_100
   ```
   
   The top level projection, `Projection: cat.sch.v.c1, cat.sch.v.c2, 
cat.sch.v.c3`, taking only `c1`, is better understood as:
   
   ```
   Column { relation: Some(Full { catalog: "cat", schema: "sch", table: "v" }), 
name: "c1" }
   ```
   
   Can see it still refers to specific catalog, schema, and table. Whereas the 
subquery alias `SubqueryAlias: cat.sch.v` has erased this since the alias is 
`cat.sch.v` as a whole


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