private RelNode genOBLogicalPlan(QB qb, Pair<RelNode, RowResolver> selPair,
        boolean outermostOB) throws SemanticException {
      QBParseInfo qbp = getQBParseInfo(qb);
      String dest = qbp.getClauseNames().iterator().next();
      ASTNode obAST = qbp.getOrderByForClause(dest);

      if (obAST == null) {
        return null;
      }

      // 1. OB Expr sanity test
      // in strict mode, in the presence of order by, limit must be
      // specified
      Integer limit = qb.getParseInfo().getDestLimit(dest);
      if (limit == null) {
        String error = StrictChecks.checkNoLimit(conf);
        if (error != null) {
          throw new SemanticException(SemanticAnalyzer.generateErrorMessage(obAST, error));
        }
      }

      RexNode offsetRN = null;
      RexNode fetchRN = null;
      if (limit != null) {
        Integer offset = qb.getParseInfo().getDestLimitOffset(dest);
        offsetRN = (offset == null || offset == 0) ?
                null : cluster.getRexBuilder().makeExactLiteral(BigDecimal.valueOf(offset));
        fetchRN = cluster.getRexBuilder().makeExactLiteral(BigDecimal.valueOf(limit));
      }

      return new OrderByRelBuilder(this, selPair, outermostOB)
              .addSortByKeys(obAST)
              .sortLimit(offsetRN, fetchRN);
    }
Generate OB RelNode and input Select RelNode that should be used to
introduce top constraining Project. If Input select RelNode is not
present then don't introduce top constraining select.

@param qb
@param selPair
@param outermostOB
@return RelNode OB RelNode
@throws SemanticException
ql/src/java/org/apache/hadoop/hive/ql/parse/CalcitePlanner.java