private RelNode genLateralViewPlans(QB qb, ASTNode lateralView, Map<String, RelNode> aliasToRel)
            throws SemanticException {
      LateralViewPlan.validateLateralView(lateralView);

      ASTNode next = (ASTNode) lateralView.getChild(1);

      // next token is either the table alias name or another lateral view (which we will call
      // recursively)
      RelNode inputRel = next.getToken().getType() == HiveParser.TOK_LATERAL_VIEW
          ? genLateralViewPlans(qb, next, aliasToRel)
          : aliasToRel.get(getTableAlias(next));

      LateralViewPlan lateralViewPlan = new LateralViewPlan(lateralView, this.cluster,
          inputRel, this.relToHiveRR.get(inputRel), unparseTranslator, conf,
          functionHelper);

      qb.addAlias(lateralViewPlan.lateralTableAlias);
      this.relToHiveColNameCalcitePosMap.put(lateralViewPlan.lateralViewRel,
          buildHiveToCalciteColumnMap(lateralViewPlan.outputRR));
      this.relToHiveRR.put(lateralViewPlan.lateralViewRel, lateralViewPlan.outputRR);
      return lateralViewPlan.lateralViewRel;
    }
Shuttle that replaces certain references with correlation variables
if needed.
ql/src/java/org/apache/hadoop/hive/ql/parse/CalcitePlanner.java