private Boolean visitCreateInnerTable()

in fastmodel-transform/fastmodel-transform-hologres/src/main/java/com/aliyun/fastmodel/transform/hologres/format/HologresAstVisitor.java [193:241]


    private Boolean visitCreateInnerTable(CreateTable node, Integer indent) {
        boolean columnEmpty = node.isColumnEmpty();
        boolean executable = !columnEmpty;
        builder.append("BEGIN;\n");
        printExtensionIfNeed(node);
        builder.append("CREATE TABLE ");
        if (node.isNotExists()) {
            builder.append("IF NOT EXISTS ");
        }
        String tableCode = getCode(node.getQualifiedName());
        builder.append(tableCode);
        String elementIndent = indentString(indent + 1);
        List<ColumnDefinition> columnDefines = merge(node.getColumnDefines(), node.getPartitionedBy());
        if (!columnEmpty) {
            builder.append(" (\n");
            String columnList = formatColumnList(columnDefines, elementIndent);
            builder.append(columnList);
            if (!node.isConstraintEmpty()) {
                appendConstraint(node, indent);
            }
            builder.append("\n").append(")");
        }
        if (!node.isPartitionEmpty()) {
            builder.append(" PARTITION BY LIST(").append(
                node.getPartitionedBy().getColumnDefinitions().stream().map(x -> formatExpression(x.getColName()))
                    .collect(joining(","))).append(")");
        }
        builder.append(";\n");
        List<Property> properties = node.getProperties();
        if (CollectionUtils.isNotEmpty(properties)) {
            String propertiesValue = buildSetProperties(node.getQualifiedName(), properties);
            builder.append(propertiesValue);
        }
        if (node.getComment() != null && node.getComment().getComment() != null) {
            builder.append(commentTable(tableCode, node.getCommentValue()));
        }
        if (!columnEmpty) {
            for (ColumnDefinition columnDefinition : columnDefines) {
                if (columnDefinition.getComment() == null || columnDefinition.getComment().getComment() == null) {
                    continue;
                }
                builder.append("\n");
                builder.append(commentColumn(tableCode, formatColName(columnDefinition.getColName(), 0), columnDefinition.getCommentValue()));
            }
        }
        builder.append("\n");
        builder.append("COMMIT;");
        return executable;
    }