public Boolean visitCreateTable()

in fastmodel-transform/fastmodel-transform-oracle/src/main/java/com/aliyun/fastmodel/transform/oracle/format/OracleVisitor.java [53:112]


    public Boolean visitCreateTable(CreateTable node, Integer indent) {
        boolean columnEmpty = node.isColumnEmpty();
        boolean executable = true;
        if (columnEmpty) {
            executable = false;
        }
        builder.append("CREATE TABLE ");
        if (node.isNotExists()) {
            builder.append("IF NOT EXISTS ");
        }
        String tableName = node.getIdentifier();
        builder.append(tableName);
        String elementIndent = indentString(indent + 1);
        if (!columnEmpty) {
            builder.append(" (\n");
            String columnList = formatColumnList(node.getColumnDefines(), elementIndent);
            builder.append(columnList);
            if (!node.isPartitionEmpty()) {
                builder.append(",\n");
                columnList = formatColumnList(node.getPartitionedBy().getColumnDefinitions(), 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 -> x.getColName().getValue())
                    .collect(joining(","))).append(")");
        }
        builder.append(";");
        if (node.getComment() != null) {
            builder.append("\n");
            builder.append(commentTable(getCode(node.getQualifiedName()), node.getCommentValue()));
        }
        if (!columnEmpty) {
            List<String> commentString = Lists.newArrayList();
            for (ColumnDefinition columnDefinition : node.getColumnDefines()) {
                if (columnDefinition.getComment() != null) {
                    String str = commentColumn(getCode(node.getQualifiedName()),
                        columnDefinition.getColName().getValue(),
                        columnDefinition.getCommentValue());
                    commentString.add(str);
                } else if (columnDefinition.getAliasValue() != null) {
                    String str = commentColumn(getCode(node.getQualifiedName()),
                        columnDefinition.getColName().getValue(),
                        columnDefinition.getAliasValue());
                    commentString.add(str);
                }
            }
            if (!commentString.isEmpty()) {
                builder.append("\n");
                builder.append(commentString.stream().collect(joining(";\n")));
            }

        }
        return executable;
    }