Search in sources :

Example 46 with SqlWriter

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

the class SqlAlterViewProperties method unparse.

@Override
public void unparse(SqlWriter writer, int leftPrec, int rightPrec) {
    super.unparse(writer, leftPrec, rightPrec);
    writer.keyword("SET");
    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 47 with SqlWriter

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

the class SqlAlterTableOptions method unparse.

@Override
public void unparse(SqlWriter writer, int leftPrec, int rightPrec) {
    super.unparse(writer, leftPrec, rightPrec);
    writer.keyword("SET");
    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 48 with SqlWriter

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

the class SqlAlterTableReset method unparse.

@Override
public void unparse(SqlWriter writer, int leftPrec, int rightPrec) {
    super.unparse(writer, leftPrec, rightPrec);
    writer.keyword("RESET");
    SqlWriter.Frame withFrame = writer.startList("(", ")");
    for (SqlNode property : propertyKeyList) {
        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 49 with SqlWriter

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

the class SqlLoadModule method unparse.

@Override
public void unparse(SqlWriter writer, int leftPrec, int rightPrec) {
    writer.keyword("LOAD MODULE");
    moduleName.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 50 with SqlWriter

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

the class SqlBetweenOperator method unparse.

public void unparse(SqlWriter writer, SqlCall call, int leftPrec, int rightPrec) {
    final SqlWriter.Frame frame = writer.startList(FRAME_TYPE, "", "");
    call.operand(VALUE_OPERAND).unparse(writer, getLeftPrec(), 0);
    writer.sep(super.getName());
    writer.sep(flag.name());
    // If the expression for the lower bound contains a call to an AND
    // operator, we need to wrap the expression in parentheses to prevent
    // the AND from associating with BETWEEN. For example, we should
    // unparse
    // a BETWEEN b OR (c AND d) OR e AND f
    // as
    // a BETWEEN (b OR c AND d) OR e) AND f
    // If it were unparsed as
    // a BETWEEN b OR c AND d OR e AND f
    // then it would be interpreted as
    // (a BETWEEN (b OR c) AND d) OR (e AND f)
    // which would be wrong.
    final SqlNode lower = call.operand(LOWER_OPERAND);
    final SqlNode upper = call.operand(UPPER_OPERAND);
    int lowerPrec = new AndFinder().containsAnd(lower) ? 100 : 0;
    lower.unparse(writer, lowerPrec, lowerPrec);
    writer.sep("AND");
    upper.unparse(writer, 0, getRightPrec());
    writer.endList(frame);
}
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