protected List<Order> getColumnNamesOrder(ASTNode ast) throws SemanticException {
    List<Order> colList = new ArrayList<>();
    int numCh = ast.getChildCount();
    for (int i = 0; i < numCh; i++) {
      ASTNode child = (ASTNode) ast.getChild(i);
      int directionCode = DirectionUtils.tokenToCode(child.getToken().getType());
      child = (ASTNode) child.getChild(0);
      if (child.getToken().getType() != HiveParser.TOK_NULLS_FIRST && directionCode == DirectionUtils.ASCENDING_CODE) {
        throw new SemanticException(
                "create/alter bucketed table: not supported NULLS LAST for SORTED BY in ASC order");
      }
      if (child.getToken().getType() != HiveParser.TOK_NULLS_LAST && directionCode == DirectionUtils.DESCENDING_CODE) {
        throw new SemanticException(
                "create/alter bucketed table: not supported NULLS FIRST for SORTED BY in DESC order");
      }
      colList.add(new Order(unescapeIdentifier(child.getChild(0).getText()).toLowerCase(), directionCode));
    }
    return colList;
  }
Get the list of FieldSchema out of the ASTNode.
Additionally, populate the primaryKeys and foreignKeys if any.
ql/src/java/org/apache/hadoop/hive/ql/parse/BaseSemanticAnalyzer.java