Description
This is a follow-up for HIVE-8920. For queries like:
from (select * from table0 union all select * from table1) s insert overwrite table table3 select s.x, count(1) group by s.x insert overwrite table table4 select s.y, count(1) group by s.y;
Currently we generate the following plan:
M1 M2 \ / \ U3 R5 | R4
It's better, however, to have the following plan:
M1 M2 |\ /| | \/ | | /\ | R4 R5
Also, we can do some reseach in this JIRA to see if it's possible
to remove UnionWork once and for all.