Search in sources :

Example 21 with SqlWriter

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

the class SqlCreateMapping method unparse.

@Override
public void unparse(SqlWriter writer, int leftPrec, int rightPrec) {
    writer.keyword("CREATE");
    if (getReplace()) {
        writer.keyword("OR REPLACE");
    }
    writer.keyword("EXTERNAL MAPPING");
    if (ifNotExists) {
        writer.keyword("IF NOT EXISTS");
    }
    name.unparse(writer, leftPrec, rightPrec);
    if (externalName != null) {
        writer.keyword("EXTERNAL NAME");
        externalName.unparse(writer, leftPrec, rightPrec);
    }
    if (columns.size() > 0) {
        SqlWriter.Frame frame = writer.startList("(", ")");
        for (SqlNode column : columns) {
            printIndent(writer);
            column.unparse(writer, 0, 0);
        }
        writer.newlineAndIndent();
        writer.endList(frame);
    }
    writer.newlineAndIndent();
    writer.keyword("TYPE");
    type.unparse(writer, leftPrec, rightPrec);
    if (options.size() > 0) {
        writer.newlineAndIndent();
        writer.keyword("OPTIONS");
        SqlWriter.Frame withFrame = writer.startList("(", ")");
        for (SqlNode property : options) {
            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 22 with SqlWriter

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

the class HazelcastValuesOperator method unparse.

@Override
public void unparse(SqlWriter writer, SqlCall call, int leftPrec, int rightPrec) {
    SqlWriter.Frame frame = writer.startList(SqlWriter.FrameTypeEnum.VALUES, "VALUES", "");
    for (SqlNode operand : call.getOperandList()) {
        writer.sep(",");
        operand.unparse(writer, 0, 0);
    }
    writer.endList(frame);
}
Also used : SqlWriter(org.apache.calcite.sql.SqlWriter) SqlNode(org.apache.calcite.sql.SqlNode)

Example 23 with SqlWriter

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

the class HazelcastMapValueConstructor method unparse.

@Override
public void unparse(SqlWriter writer, SqlCall call, int leftPrec, int rightPrec) {
    writer.keyword(getName());
    SqlWriter.Frame frame = writer.startList("[", "]");
    for (SqlNode operand : call.getOperandList()) {
        writer.sep(",");
        operand.unparse(writer, leftPrec, rightPrec);
    }
    writer.endList(frame);
}
Also used : SqlWriter(org.apache.calcite.sql.SqlWriter) SqlNode(org.apache.calcite.sql.SqlNode)

Example 24 with SqlWriter

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

the class HazelcastJsonArrayFunction method unparse.

@Override
public void unparse(final SqlWriter writer, final SqlCall call, final int leftPrec, final int rightPrec) {
    final SqlWriter.Frame frame = writer.startFunCall(this.getName());
    if (call.operandCount() == 1) {
        writer.endFunCall(frame);
        return;
    }
    for (int i = 1; i < call.operandCount(); i++) {
        writer.sep(",");
        call.operand(i).unparse(writer, leftPrec, rightPrec);
    }
    final SqlJsonConstructorNullClause nullClause = (SqlJsonConstructorNullClause) ((SqlLiteral) call.operand(0)).getValue();
    switch(nullClause) {
        case ABSENT_ON_NULL:
            writer.keyword("ABSENT ON NULL");
            break;
        case NULL_ON_NULL:
            writer.keyword("NULL ON NULL");
            break;
        default:
            throw QueryException.error("Unknown SqlJsonConstructorNullClause constant: " + nullClause);
    }
    writer.endFunCall(frame);
}
Also used : SqlWriter(org.apache.calcite.sql.SqlWriter) SqlJsonConstructorNullClause(org.apache.calcite.sql.SqlJsonConstructorNullClause)

Example 25 with SqlWriter

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

the class HazelcastJsonObjectFunction method unparse.

@Override
public void unparse(final SqlWriter writer, final SqlCall call, final int leftPrec, final int rightPrec) {
    final SqlWriter.Frame frame = writer.startFunCall(this.getName());
    if (call.operandCount() == 1) {
        writer.endFunCall(frame);
        return;
    }
    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);
    }
    final SqlJsonConstructorNullClause nullClause = (SqlJsonConstructorNullClause) ((SqlLiteral) call.operand(0)).getValue();
    switch(nullClause) {
        case ABSENT_ON_NULL:
            writer.keyword("ABSENT ON NULL");
            break;
        case NULL_ON_NULL:
            writer.keyword("NULL ON NULL");
            break;
        default:
            throw QueryException.error("Unknown SqlJsonConstructorNullClause constant: " + nullClause);
    }
    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