facebook/presto — pull request #1937 by zhenxiao (2014-11-08 23:48:54+00:00)
Title: Optimize joins with similar subqueries

Follow
https://github.com/facebook/presto/issues/1732

A first step, optimize queries of the following shape:

SELECT *
FROM (
SELECT k, agg1, agg2
FROM t
GROUP BY k
) a
JOIN (
SELECT k, agg3, agg4
FROM t
GROUP BY k
) b
ON (a.k = b.k)

as

SELECT k, agg1, agg2, agg3, agg4
FROM T
GROUP BY k