...
Recently a lot of work has been done to extend support for subqueries (HIVE-15456). But this work primarily targeted extending subquery support in WHERE and HAVING clauses. We plan to continue the work done in HIVE-15456 to support subqueries in a select list (see HIVE-16091).
Assumptions
We plan to limit the scope with the following assumptions and limitations.
...
Design for this will be similar to the work done in HIVE-15456.
- genLogicalPlan will go over the select list to do the following:
- If subquery is not a top-level expression, throw an error.
- Otherwise, generate an appropriate plan by using RexSubquery to represent the subquery.
- HiveSubqueryRemoveRule will then be applied to remove the RexSubquery node and rewrite the query into a join.
- HiveRelDecorrelator::decorrelateQuery will then be used to decorrelate correlated queries.
HIVE-16091 covers the initial work for supporting subqueries in SELECT.