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

   ### Describe the bug
   
   Calling `column_refs()` on a subquery expression returns no column 
references, even if the subquery contains outer references.
   
   PushDownFilter optimization uses the `column_refs()` to compare against the 
columns returned from `prevent_predicate_push_down_columns()` on an extension 
node. The effect of this is that a subquery in a filter may get pushed below an 
extension node when it shouldn't. 
   
   ### To Reproduce
   
   ```rust
       let outer_ref = Expr::OuterReferenceColumn(DataType::Int64, 
Column::new(None::<String>, "a"));
       let plan = LogicalPlanBuilder::empty(true)
           .project(vec![outer_ref.clone()])
           .unwrap()
           .build()
           .unwrap();
   
       let subq = Subquery {
           subquery: Arc::new(plan),
           outer_ref_columns: vec![outer_ref],
       };
   
       let expr = Expr::Exists(Exists::new(subq, false));
   
       println!("{:?}", expr.column_refs());
   ```
   
   ### Expected behavior
   
   `column_refs()` should return the outer columns used by the subquery 
expression.
   
   ### Additional context
   
   The relevant code is 
[here](https://github.com/apache/datafusion/blob/main/datafusion/expr/src/expr.rs#L1533).
 It just collects `Expr::Column`s within self.


-- 
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-unsubscr...@datafusion.apache.org.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org
For additional commands, e-mail: github-h...@datafusion.apache.org

Reply via email to