private boolean runSharedWorkOptimization(ParseContext pctx, SharedWorkOptimizerCache optimizerCache, List<TableScanOperator> scans,
      Mode mode) throws SemanticException {
    boolean ret = false;
    ret |= sharedWorkOptimization(pctx, optimizerCache, scans, mode, false);
    if (pctx.getConf().getBoolVar(ConfVars.HIVE_SHARED_WORK_MERGE_TS_SCHEMA)) {
      ret |= sharedWorkOptimization(pctx, optimizerCache, scans, mode, true);
    }
    return ret;
  }
Shared computation optimizer.

<p>Originally, this rule would find scan operators over the same table
in the query plan and merge them if they met some preconditions.
<pre>
 TS   TS             TS
 |    |     -&gt;   /  \
 Op   Op           Op  Op
</pre>
<p>Now the rule has been extended to find opportunities to other operators
downstream, not only a single table scan.

 TS1   TS2    TS1   TS2            TS1   TS2
  |     |      |     |              |     |
  |    RS      |    RS              |    RS
   \   /        \   /       -&gt;    \   /
  MapJoin      MapJoin              MapJoin
     |            |                  /   \
     Op           Op                Op   Op

<p>If the extended version of the optimizer is enabled, it can go beyond
a work boundary to find reutilization opportunities.

<p>The optimization only works with the Tez execution engine.
ql/src/java/org/apache/hadoop/hive/ql/optimizer/SharedWorkOptimizer.java