private ASTNode getWindowRangeAST(RexWindow window) {
      ASTNode wRangeAst = null;

      ASTNode startAST = null;
      boolean lbUnbounded = false;
      RexWindowBound lb = window.getLowerBound();
      if (lb != null) {
        startAST = getWindowBound(lb);
        lbUnbounded = lb.isUnbounded();
      }

      ASTNode endAST = null;
      boolean ubUnbounded = false;
      RexWindowBound ub = window.getUpperBound();
      if (ub != null) {
        endAST = getWindowBound(ub);
        ubUnbounded = ub.isUnbounded();
      }

      if (startAST != null || endAST != null) {
        // NOTE: in Hive AST Rows->Range(Physical) & Range -> Values (logical)
        // In Calcite, "ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING"
        // is represented as "RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING"
        // since they are equivalent. However, in Hive, it is most commonly represented
        // as "ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING".
        if (window.isRows() || (lbUnbounded && ubUnbounded)) {
          wRangeAst = ASTBuilder.createAST(HiveParser.TOK_WINDOWRANGE, "TOK_WINDOWRANGE");
        } else {
          wRangeAst = ASTBuilder.createAST(HiveParser.TOK_WINDOWVALUES, "TOK_WINDOWVALUES");
        }
        if (startAST != null) {
          wRangeAst.addChild(startAST);
        }
        if (endAST != null) {
          wRangeAst.addChild(endAST);
        }
      }

      return wRangeAst;
    }
Add PK-FK join information to the AST as a query hint
@param ast
@param join
@param swapSides whether the left and right input of the join is swapped
ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/translator/ASTConverter.java