bvolpato-dd opened a new issue, #18066:
URL: https://github.com/apache/datafusion/issues/18066

   ### Describe the bug
   
   For certain queries with subqueries, DataFusion optimizes them as a LEFT 
join without condition (`ScalarSubqueryToJoin`).
   
   A recent addition to require conditions for joins 
(https://github.com/apache/datafusion/pull/15334) has added the validation that 
causes problems in this type of query now:
   
   ```
   ---- cases::roundtrip_logical_plan::scalar_subquery_in_select stdout ----
   Error: Plan("join condition should not be empty")
   ```
   
   
   
   ### To Reproduce
   
   
   ```sql
   SELECT a, (SELECT MAX(b) FROM data2) as max_b FROM data
   ```
   Returns error:
   
   > Error: Plan("join condition should not be empty")
   
   
   ### Expected behavior
   
   No conditions necessary:
   
   ```
   Projection: data.a, max(data2.b) AS max_b
     Left Join: 
       TableScan: data projection=[a]
       Aggregate: groupBy=[[]], aggr=[[max(data2.b)]]
         TableScan: data2 projection=[b], partial_filters=[Boolean(true)]
   ```
   
   
   
   ### Additional context
   
   _No response_


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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to