Had a offline discussion with Paul yesterday.
This is a followup on https://issues.apache.org/jira/browse/HIVE-935
Say, the query is
select .. from T LATERAL VIEW explode(c2_list) as c2 LATERAL VIEW explode(c3_list) as c3
If we follow the suggestion from https://issues.apache.org/jira/browse/HIVE-935,
(Lateral View Join operator will always have 2 inputs - the inputs will not be merged like join),
the explode operator for c3_list will be called once for each input on c2, which can be expensive.
Instead, if we merge the inputs and let LATERAL VIEW have 3 inputs, we will be invoking explode
operator for c3_list once for each row.
So, merging should be performed when the right side lateral views are not referencing anything from the
left side lateral views.