Search in sources :

Example 11 with SqlWriter

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

the class SqlCreateHiveTable method unparsePropList.

private void unparsePropList(SqlNodeList propList, SqlWriter writer, int leftPrec, int rightPrec) {
    SqlWriter.Frame withFrame = writer.startList("(", ")");
    for (SqlNode property : propList) {
        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 12 with SqlWriter

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

the class SqlAddReplaceColumns method unparse.

@Override
public void unparse(SqlWriter writer, int leftPrec, int rightPrec) {
    super.unparse(writer, leftPrec, rightPrec);
    if (replace) {
        writer.keyword("REPLACE");
    } else {
        writer.keyword("ADD");
    }
    writer.keyword("COLUMNS");
    SqlWriter.Frame frame = writer.startList(SqlWriter.FrameTypeEnum.create("sds"), "(", ")");
    for (SqlNode column : newColumns) {
        printIndent(writer);
        column.unparse(writer, leftPrec, rightPrec);
    }
    writer.newlineAndIndent();
    writer.endList(frame);
}
Also used : SqlWriter(org.apache.calcite.sql.SqlWriter) SqlNode(org.apache.calcite.sql.SqlNode)

Example 13 with SqlWriter

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

the class SqlDropPartitions method unparse.

@Override
public void unparse(SqlWriter writer, int leftPrec, int rightPrec) {
    super.unparse(writer, leftPrec, rightPrec);
    writer.newlineAndIndent();
    writer.keyword("DROP");
    if (ifExists) {
        writer.keyword("IF EXISTS");
    }
    int opLeftPrec = getOperator().getLeftPrec();
    int opRightPrec = getOperator().getRightPrec();
    final SqlWriter.Frame frame = writer.startList("", "");
    for (SqlNodeList partSpec : partSpecs) {
        writer.sep(",");
        writer.newlineAndIndent();
        writer.keyword("PARTITION");
        partSpec.unparse(writer, opLeftPrec, opRightPrec);
    }
    writer.endList(frame);
}
Also used : SqlWriter(org.apache.calcite.sql.SqlWriter) SqlNodeList(org.apache.calcite.sql.SqlNodeList)

Example 14 with SqlWriter

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

the class SqlCreateCatalog method unparse.

@Override
public void unparse(SqlWriter writer, int leftPrec, int rightPrec) {
    writer.keyword("CREATE CATALOG");
    catalogName.unparse(writer, leftPrec, rightPrec);
    if (this.propertyList.size() > 0) {
        writer.keyword("WITH");
        SqlWriter.Frame withFrame = writer.startList("(", ")");
        for (SqlNode property : propertyList) {
            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 15 with SqlWriter

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

the class SqlJsonObjectFunction method unparse.

@Override
public void unparse(SqlWriter writer, SqlCall call, int leftPrec, int rightPrec) {
    assert call.operandCount() % 2 == 1;
    final SqlWriter.Frame frame = writer.startFunCall(getName());
    SqlWriter.Frame listFrame = writer.startList("", "");
    for (int i = 1; i < call.operandCount(); i += 2) {
        writer.sep(",");
        writer.keyword("KEY");
        call.operand(i).unparse(writer, leftPrec, rightPrec);
        writer.keyword("VALUE");
        call.operand(i + 1).unparse(writer, leftPrec, rightPrec);
    }
    writer.endList(listFrame);
    SqlJsonConstructorNullClause nullClause = getEnumValue(call.operand(0));
    switch(nullClause) {
        case ABSENT_ON_NULL:
            writer.keyword("ABSENT ON NULL");
            break;
        case NULL_ON_NULL:
            writer.keyword("NULL ON NULL");
            break;
        default:
            throw new IllegalStateException("unreachable code");
    }
    writer.endFunCall(frame);
}
Also used : SqlWriter(org.apache.calcite.sql.SqlWriter) SqlJsonConstructorNullClause(org.apache.calcite.sql.SqlJsonConstructorNullClause)

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