Problem

Currently Hive doesn't support subqueries in a SELECT statement, for example, the following query will not run on Hive:

SELECT customer.customer_num,
	(SELECT SUM(ship_charge) 
		FROM orders
		WHERE customer.customer_num = orders.customer_num
	) AS total_ship_chg
FROM customer 

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

Given the assumptions above, the following kind of subqueries could be used in SELECT. 

All of the above queries could be correlated or uncorrelated.

Design for this will be similar to the work done in HIVE-15456 .

 HIVE-16091  covers the initial work for supporting subqueries in SELECT.

首页