Skip to content

Expression column_refs does not return outer referenced columns in subqueries #15046

Closed

Description

@helgikrs

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

    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. It just collects Expr::Columns within self.

Activity

  1. jatin510 commented on Mar 6, 2025

    @jatin510
    Contributor

    take

  2. added a commit that references this issue on Oct 2, 2026
    379c07b
  3. added a commit that references this issue on Oct 6, 2026
    8f4c51f
  4. added a commit that references this issue on Oct 11, 2026
    8eea52c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions