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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to