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

   ### Describe the bug
   
   `decorrelate_where_in` currently only support `Predicate` as the top level 
plan in the sub-queries, otherwise it will return an error:
   
https://github.com/apache/arrow-datafusion/blob/667f19ebad216b7592af5a91b70a24fb21c3bb64/datafusion/optimizer/src/decorrelate_where_in.rs#L151-L152
   
   However, for limit subquery, the top level plan might be `Limit` which let 
`decorrelate_where_in` fail.
   
   ### To Reproduce
   
   Set `skip_failed_rules` to `false` and run the test 
`support_limit_subquery`, you will fail on the test with the error message
   ```
   Error: Context("decorrelate_where_in", Internal("Optimizer rule 
'decorrelate_where_in' failed due to unexpected error: a projection is required 
at datafusion/optimizer/src/decorrelate_where_in.rs:152\ncaused by\nError 
during planning: Could not coerce into Projection! at 
datafusion/expr/src/logical_plan/plan.rs:1293"))
   test sql::subqueries::support_limit_subquery ... FAILED
   ```
   
   ### Expected behavior
   
   No error should be generated. At least, we can let `decorrelate_where_in` 
return `Ok(None)`
   
   ### 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]

Reply via email to