public PTFInvocationSpec.OrderSpec processOrderSpec(ASTNode sortNode) {
    PTFInvocationSpec.OrderSpec oSpec = new PTFInvocationSpec.OrderSpec();
    int exprCnt = sortNode.getChildCount();
    for (int i = 0; i < exprCnt; i++) {
      PTFInvocationSpec.OrderExpression exprSpec = new PTFInvocationSpec.OrderExpression();
      ASTNode orderSpec = (ASTNode) sortNode.getChild(i);
      ASTNode nullOrderSpec = (ASTNode) orderSpec.getChild(0);
      exprSpec.setExpression((ASTNode) nullOrderSpec.getChild(0));
      if (orderSpec.getType() == HiveParser.TOK_TABSORTCOLNAMEASC) {
        exprSpec.setOrder(ASC);
      } else {
        exprSpec.setOrder(DESC);
      }
      if (nullOrderSpec.getType() == HiveParser.TOK_NULLS_FIRST) {
        exprSpec.setNullOrder(NULLS_FIRST);
      } else {
        exprSpec.setNullOrder(NULLS_LAST);
      }
      oSpec.addExpression(exprSpec);
    }
    return oSpec;
  }
Called when we end analysis of a query.
ql/src/java/org/apache/hadoop/hive/ql/parse/BaseSemanticAnalyzer.java