Follow-up of the work in
HIVE-16867. HIVE-16867 introduced an optimization that identifies scans on input tables that can be merged and reuses the computation that is done in the work containing those scans. In particular, we traverse both parts of the plan upstream and reuse the operators if possible.
Currently, the optimizer will not go beyond the output edge(s) of that work. This extension removes that limitation.