public Node visitColumnCreateTable()

in fastmodel-transform/fastmodel-transform-adbmysql/src/main/java/com/aliyun/fastmodel/transform/adbmysql/parser/visitor/AdbMysqlAstBuilder.java [171:222]


    public Node visitColumnCreateTable(ColumnCreateTableContext ctx) {
        List<Property> properties = ImmutableList.of();
        List<TableOptionContext> tableOptionContexts = ctx.tableOption();
        if (CollectionUtils.isNotEmpty(tableOptionContexts)) {
            properties = ParserHelper.visit(this, tableOptionContexts, Property.class);
        }
        List<ColumnDefinition> columnDefinitions = ImmutableList.of();
        List<TableIndex> tableIndexList = ImmutableList.of();
        List<BaseConstraint> constraints = Lists.newArrayList();
        CreateDefinitionsContext definitions = ctx.createDefinitions();
        if (definitions != null) {
            List<Node> nodes = ParserHelper.visit(this, definitions.createDefinition(), Node.class);
            columnDefinitions = nodes.stream().filter(x -> x instanceof ColumnDefinition).map(x -> (ColumnDefinition)x).collect(Collectors.toList());
            constraints = nodes.stream().filter(x -> x instanceof BaseConstraint).map(x -> (BaseConstraint)x).collect(Collectors.toList());

            tableIndexList = nodes.stream().filter(x -> x instanceof TableIndex).map(x -> (TableIndex)x).collect(Collectors.toList());
        }
        PartitionedBy partitionedBy = null;
        if (ctx.partitionDefinitions() != null) {
            PartitionFunctionDefinitionContext partitionFunctionDefinitionContext = ctx.partitionDefinitions().partitionFunctionDefinition();
            partitionedBy = visitIfPresent(this, partitionFunctionDefinitionContext, PartitionedBy.class).orElse(null);
        }

        Property commentProperties = getCommentProperty(properties);
        List<Property> propertyList = properties.stream().filter(p -> !p.getName().equalsIgnoreCase(COMMENT)).collect(Collectors.toList());
        if (partitionedBy != null) {
            visitIfPresent(this, ctx.partitionDefinitions().lifeCycle(), Property.class).ifPresent(propertyList::add);
        }
        //build external table
        if (ctx.ext != null) {
            Property property = new Property(AdbMysqlPropertyKey.EXTERNAL.getValue(), BooleanLiteral.TRUE);
            propertyList.add(property);
        }
        if (ctx.tableAttribute() != null) {
            BaseConstraint constraint = (BaseConstraint)visit(ctx.tableAttribute());
            constraints.add(constraint);
        }

        Comment comment = commentProperties != null ? new Comment(commentProperties.getValue())
            : null;
        return CreateTable.builder()
            .tableName(getQualifiedName(ctx.tableName()))
            .detailType(reverseContext.getReverseTableType())
            .columns(columnDefinitions)
            .constraints(constraints)
            .properties(propertyList)
            .partition(partitionedBy)
            .comment(comment)
            .tableIndex(tableIndexList)
            .ifNotExist(ctx.ifNotExists() != null)
            .build();
    }