private RexNode getOrderByExpression(
            RowResolver selectOutputRR, RowResolver inputRR, ASTNode ref)
            throws SemanticException {
      // first try to get it from select
      // in case of udtf, selectOutputRR may be null.
      RexNode orderByExpression = null;
      if (selectOutputRR != null) {
        try {
          Map<ASTNode, RexNode> astToExprNDescMap = genAllRexNode(
                  ref, selectOutputRR, calcitePlannerAction.cluster.getRexBuilder());
          orderByExpression = astToExprNDescMap.get(ref);
        } catch (SemanticException ex) {
          // we can tolerate this as this is the previous behavior
          LOG.debug("Can not find column in {} The error msg is {}", ref.getText(), ex.getMessage());
        }
      }
      // then try to get it from all
      if (orderByExpression == null) {
        Map<ASTNode, RexNode> astToExprNDescMap = genAllRexNode(
                ref, inputRR, calcitePlannerAction.cluster.getRexBuilder());
        orderByExpression = astToExprNDescMap.get(ref);
      }
      if (orderByExpression == null) {
        throw new SemanticException("Invalid order by expression: " + ref.toString());
      }
      return orderByExpression;
    }
This method can be called at startup time to pre-register all the
additional Hive classes (compared to Calcite core classes) that may
be visited during the planning phase in the metadata providers
and the field trimmer.
ql/src/java/org/apache/hadoop/hive/ql/parse/CalcitePlanner.java