build_join

Function build_join 

Source
fn build_join(
    subquery: &Subquery,
    filter_input: &LogicalPlan,
    subquery_alias: &str,
) -> Result<Option<(LogicalPlan, HashMap<String, Expr>)>>
Expand description

Takes a query like:

select id from customers where balance >
    (select avg(total) from orders where orders.c_id = customers.id)

and optimizes it into:

select c.id from customers c
left join (select c_id, avg(total) as val from orders group by c_id) o on o.c_id = c.c_id
where c.balance > o.val

Or a query like:

select id from customers where balance >
    (select avg(total) from orders)

and optimizes it into:

select c.id from customers c
left join (select avg(total) as val from orders) a
where c.balance > a.val

ยงArguments

  • query_info - The subquery portion of the where (select avg(total) from orders)
  • filter_input - The non-subquery portion (from customers)
  • outer_others - Any additional parts to the where expression (and c.x = y)
  • subquery_alias - Subquery aliases