public Boolean visitCreateTable()

in fastmodel-transform/fastmodel-transform-doris/src/main/java/com/aliyun/fastmodel/transform/doris/format/DorisOutVisitor.java [82:155]


    public Boolean visitCreateTable(CreateTable node, Integer indent) {
        boolean columnEmpty = node.isColumnEmpty();
        //maxcompute不支持没有列的表
        boolean executable = !columnEmpty;
        builder.append("CREATE TABLE ");
        if (node.isNotExists()) {
            builder.append("IF NOT EXISTS ");
        }
        String tableName = getCode(node.getQualifiedName());
        builder.append(tableName);
        if (!columnEmpty) {
            builder.append("\n(\n");
            String elementIndent = indentString(indent + 1);
            String columnList = formatColumnList(node.getColumnDefines(), elementIndent);
            builder.append(columnList);

            if (!node.isIndexEmpty()) {
                for (TableIndex tableIndex : node.getTableIndexList()) {
                    builder.append(",\n");
                    process(tableIndex, indent + 1);
                }
            }
            builder.append("\n").append(")");
        }

        //format engine
        if (node.getProperties() != null) {
            Optional<Property> first = node.getProperties().stream().filter(
                p -> StringUtils.equalsIgnoreCase(p.getName(), TABLE_ENGINE.getValue())).findFirst();
            first.ifPresent(property -> builder.append("\nENGINE=").append(property.getValue()));
        }

        //key constraint
        if (!node.isConstraintEmpty()) {
            List<BaseConstraint> keyConstraint = node.getConstraintStatements().stream().filter(
                c -> !(c instanceof NonKeyConstraint)).collect(Collectors.toList());
            appendConstraint(keyConstraint, indent);
        }

        if (node.getComment() != null) {
            builder.append("\n");
            builder.append(formatComment(node.getComment(), true));
        }
        //format partitioned by
        if (!node.isPartitionEmpty()) {
            builder.append("\n");
            process(node.getPartitionedBy(), indent);
        } else {
            String propertyValue = PropertyUtil.getPropertyValue(node.getProperties(), TABLE_PARTITION_RAW.getValue());
            if (StringUtils.isNotBlank(propertyValue)) {
                builder.append("\n");
                builder.append(propertyValue);
            }
        }

        //non key constraint
        if (!node.isConstraintEmpty()) {
            List<BaseConstraint> nonKeyConstraint = node.getConstraintStatements().stream().filter(
                c -> c instanceof NonKeyConstraint).collect(Collectors.toList());
            appendConstraint(nonKeyConstraint, indent);
        }

        if (!node.isPropertyEmpty()) {
            String prop = formatProperty(node.getProperties());
            if (StringUtils.isNotBlank(prop)) {
                builder.append("\n");
                builder.append("PROPERTIES (");
                builder.append(prop);
                builder.append(")");
            }
        }
        builder.append(";");
        return executable;
    }