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/11/14 02:04:12 UTC

[GitHub] [arrow-datafusion] ygf11 opened a new issue, #4196: Add ambiguous check when generate selection plan

ygf11 opened a new issue, #4196:
URL: https://github.com/apache/arrow-datafusion/issues/4196

   **Describe the bug**
   Datafusion will try to generate inner join plan for selection, but it does not do ambiguous check.  
   For example:
   ```sql
   ❯ explain select * from test0, test1 where c0 = c0 + 1;
   +---------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   | plan_type     | plan                                                                                                                                                                    |
   +---------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   | logical_plan  | Projection: test0.c0, test0.c1, test0.c2, test0.c3, test0.c4, test0.c5, test1.c0, test1.c1, test1.c2, test1.c3, test1.c4, test1.c5                                      |
   |               |   CrossJoin:                                                                                                                                                            |
   |               |     Projection: test0.c0, test0.c1, test0.c2, test0.c3, test0.c4, test0.c5                                                                                              |
   |               |       Filter: CAST(test0.c0 AS Int64)test0.c0 = CAST(test0.c0 AS Int64)test0.c0 + Int64(1)                                                                              |
   |               |         Projection: CAST(test0.c0 AS Int64) AS CAST(test0.c0 AS Int64)test0.c0, test0.c0, test0.c1, test0.c2, test0.c3, test0.c4, test0.c5                              |
   |               |           TableScan: test0 projection=[c0, c1, c2, c3, c4, c5], partial_filters=[CAST(test0.c0 AS Int64) = CAST(test0.c0 AS Int64) + Int64(1)]                          |
   |               |     TableScan: test1 projection=[c0, c1, c2, c3, c4, c5]        
   ```
   
   In `PostgreSQL`, this will throw an error:
   ```sql
   psql -d "$POSTGRES_DB" -h "$POSTGRES_HOST" -p "$POSTGRES_PORT" -U "$POSTGRES_USER" -c "explain select * from test0, test1 where c0 = c0 + 1"
   ERROR:  column reference "c0" is ambiguous
   LINE 1: explain select * from test0, test1 where c0 = c0 + 1
   ```
   
   The semantics of this sql is not clear, we need throw exception like `PostgreSQL` do.
   
   
   **To Reproduce**
   Create two tables -- test0 and test1, which has same schema.
   
   run sql `select * from test0, test1 where c0 = c0 + 1`.
   
   **Expected behavior**
   
   **Additional context**
   


-- 
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.apache.org

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


[GitHub] [arrow-datafusion] alamb closed issue #4196: Add ambiguous check when generate selection plan

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb closed issue #4196: Add ambiguous check when generate selection plan
URL: https://github.com/apache/arrow-datafusion/issues/4196


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