vishalkotak opened a new issue, #27764:
URL: https://github.com/apache/datafusion/issues/27764

   ### Describe the bug
   
   A correlated `EXISTS` subquery fails to plan when it is correlated through a 
non-equality condition and has a `HAVING` clause.
   
   ### To Reproduce
   
   ```sql
   CREATE TABLE t1(a INT) AS VALUES (1), (2), (3);
   CREATE TABLE t2(a INT) AS VALUES (2), (3), (3);
   
   SELECT a FROM t1 WHERE EXISTS (SELECT 1 FROM t2 WHERE t2.a > t1.a HAVING 
count(*) > 1);
   ```
   
   fails with:
   
   ```
   This feature is not implemented: Physical plan does not support logical 
expression Exists(Exists { subquery: <subquery>, negated: false })
   ```
   
   `NOT EXISTS` fails the same way. The query works with `t2.a = t1.a`, or 
without the `HAVING`.
   
   ### Expected behavior
   
   It should return 1 and 2, as DuckDB does.
   
   ### Additional context
   
   Found by comparing query results against DuckDB on random queries. Tested on 
main.
   
   ### Willingness to contribute
   
   Happy to look at this later if nobody picks it up.
   


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