Search in sources :

Example 36 with SqlWriter

use of org.apache.calcite.sql.SqlWriter in project calcite by apache.

the class SqlCreateView method unparse.

@Override
public void unparse(SqlWriter writer, int leftPrec, int rightPrec) {
    if (getReplace()) {
        writer.keyword("CREATE OR REPLACE");
    } else {
        writer.keyword("CREATE");
    }
    writer.keyword("VIEW");
    name.unparse(writer, leftPrec, rightPrec);
    if (columnList != null) {
        SqlWriter.Frame frame = writer.startList("(", ")");
        for (SqlNode c : columnList) {
            writer.sep(",");
            c.unparse(writer, 0, 0);
        }
        writer.endList(frame);
    }
    writer.keyword("AS");
    writer.newlineAndIndent();
    query.unparse(writer, 0, 0);
}
Also used : SqlWriter(org.apache.calcite.sql.SqlWriter) SqlNode(org.apache.calcite.sql.SqlNode)

Example 37 with SqlWriter

use of org.apache.calcite.sql.SqlWriter in project calcite by apache.

the class SqlUploadJarNode method unparseAlterOperation.

@Override
protected void unparseAlterOperation(SqlWriter writer, int leftPrec, int rightPrec) {
    writer.keyword("UPLOAD");
    writer.keyword("JAR");
    SqlWriter.Frame frame = writer.startList("", "");
    for (SqlNode jarPath : jarPaths) {
        jarPath.unparse(writer, leftPrec, rightPrec);
    }
    writer.endList(frame);
}
Also used : SqlWriter(org.apache.calcite.sql.SqlWriter) SqlNode(org.apache.calcite.sql.SqlNode)

Example 38 with SqlWriter

use of org.apache.calcite.sql.SqlWriter in project flink by apache.

the class SqlAlterHiveTableAddReplaceColumn method unparse.

@Override
public void unparse(SqlWriter writer, int leftPrec, int rightPrec) {
    writer.keyword("ALTER TABLE");
    tableIdentifier.unparse(writer, leftPrec, rightPrec);
    SqlNodeList partitionSpec = getPartitionSpec();
    if (partitionSpec != null && partitionSpec.size() > 0) {
        writer.keyword("PARTITION");
        partitionSpec.unparse(writer, getOperator().getLeftPrec(), getOperator().getRightPrec());
    }
    if (isReplace()) {
        writer.keyword("REPLACE");
    } else {
        writer.keyword("ADD");
    }
    writer.keyword("COLUMNS");
    SqlWriter.Frame frame = writer.startList(SqlWriter.FrameTypeEnum.create("sds"), "(", ")");
    for (SqlNode column : origColumns) {
        printIndent(writer);
        column.unparse(writer, leftPrec, rightPrec);
    }
    writer.newlineAndIndent();
    writer.endList(frame);
    if (cascade) {
        writer.keyword("CASCADE");
    } else {
        writer.keyword("RESTRICT");
    }
}
Also used : SqlWriter(org.apache.calcite.sql.SqlWriter) SqlNodeList(org.apache.calcite.sql.SqlNodeList) SqlNode(org.apache.calcite.sql.SqlNode)

Example 39 with SqlWriter

use of org.apache.calcite.sql.SqlWriter in project flink by apache.

the class SqlAlterHiveTableProps method unparse.

@Override
public void unparse(SqlWriter writer, int leftPrec, int rightPrec) {
    super.unparse(writer, leftPrec, rightPrec);
    writer.keyword("SET TBLPROPERTIES");
    SqlWriter.Frame withFrame = writer.startList("(", ")");
    for (SqlNode property : origProps) {
        printIndent(writer);
        property.unparse(writer, leftPrec, rightPrec);
    }
    writer.newlineAndIndent();
    writer.endList(withFrame);
}
Also used : SqlWriter(org.apache.calcite.sql.SqlWriter) SqlNode(org.apache.calcite.sql.SqlNode)

Example 40 with SqlWriter

use of org.apache.calcite.sql.SqlWriter in project flink by apache.

the class SqlAlterHiveTableSerDe method unparse.

@Override
public void unparse(SqlWriter writer, int leftPrec, int rightPrec) {
    super.unparse(writer, leftPrec, rightPrec);
    writer.keyword("SET");
    if (serdeLib != null) {
        writer.keyword("SERDE");
        serdeLib.unparse(writer, leftPrec, rightPrec);
    }
    if (origSerDeProps != null && origSerDeProps.size() > 0) {
        if (serdeLib == null) {
            writer.keyword("SERDEPROPERTIES");
        } else {
            writer.keyword("WITH SERDEPROPERTIES");
        }
        SqlWriter.Frame withFrame = writer.startList("(", ")");
        for (SqlNode property : origSerDeProps) {
            printIndent(writer);
            property.unparse(writer, leftPrec, rightPrec);
        }
        writer.newlineAndIndent();
        writer.endList(withFrame);
    }
}
Also used : SqlWriter(org.apache.calcite.sql.SqlWriter) SqlNode(org.apache.calcite.sql.SqlNode)

Aggregations

SqlWriter (org.apache.calcite.sql.SqlWriter)48 SqlNode (org.apache.calcite.sql.SqlNode)40 SqlNodeList (org.apache.calcite.sql.SqlNodeList)5 SqlNode (org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.sql.SqlNode)4 SqlWriter (org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.sql.SqlWriter)4 SqlJsonConstructorNullClause (org.apache.calcite.sql.SqlJsonConstructorNullClause)3 SqlIdentifier (org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.sql.SqlIdentifier)2 SqlPrettyWriter (org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.sql.pretty.SqlPrettyWriter)2 SqlLiteral (org.apache.calcite.sql.SqlLiteral)2 SqlTableConstraint (org.apache.flink.sql.parser.ddl.constraint.SqlTableConstraint)2 Test (org.junit.Test)2 ColumnMetadata (com.datastax.driver.core.ColumnMetadata)1 MaterializedViewMetadata (com.datastax.driver.core.MaterializedViewMetadata)1 HazelcastSqlCase (com.hazelcast.jet.sql.impl.validate.operators.special.HazelcastSqlCase)1 PrintWriter (java.io.PrintWriter)1 StringWriter (java.io.StringWriter)1 ArrayList (java.util.ArrayList)1 TimeUnitRange (org.apache.calcite.avatica.util.TimeUnitRange)1 CalciteSchema (org.apache.calcite.jdbc.CalciteSchema)1 SchemaPlus (org.apache.calcite.schema.SchemaPlus)1