public static TypeInfo getComplexTypeTypeInfo(ASTNode typeNode) throws SemanticException {
    switch (typeNode.getType()) {
      case HiveParser.TOK_LIST:
        ListTypeInfo listTypeInfo = new ListTypeInfo();
        listTypeInfo.setListElementTypeInfo(getComplexTypeTypeInfo((ASTNode) typeNode.getChild(0)));
        return listTypeInfo;
      case HiveParser.TOK_MAP:
        MapTypeInfo mapTypeInfo = new MapTypeInfo();
        String keyTypeString = getTypeStringFromAST((ASTNode) typeNode.getChild(0));
        mapTypeInfo.setMapKeyTypeInfo(TypeInfoFactory.getPrimitiveTypeInfo(keyTypeString));
        mapTypeInfo.setMapValueTypeInfo(getComplexTypeTypeInfo((ASTNode) typeNode.getChild(1)));
        return mapTypeInfo;
      case HiveParser.TOK_STRUCT:
        StructTypeInfo structTypeInfo = new StructTypeInfo();
        Map<String, TypeInfo> fields = collectStructFieldNames(typeNode);
        structTypeInfo.setAllStructFieldNames(new ArrayList<>(fields.keySet()));
        structTypeInfo.setAllStructFieldTypeInfos(new ArrayList<>(fields.values()));
        return structTypeInfo;
      default:
        String typeString = getTypeStringFromAST(typeNode);
        return TypeInfoFactory.getPrimitiveTypeInfo(typeString);
    }
  }
Parse the newly generated SQL statement to get a new AST.
ql/src/java/org/apache/hadoop/hive/ql/parse/ParseUtils.java