use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.sql.SqlWriter in project flink by apache.
the class SqlCreateHiveDatabase method unparse.
@Override
public void unparse(SqlWriter writer, int leftPrec, int rightPrec) {
writer.keyword("CREATE DATABASE");
if (isIfNotExists()) {
writer.keyword("IF NOT EXISTS");
}
getDatabaseName().unparse(writer, leftPrec, rightPrec);
if (getComment().isPresent()) {
writer.newlineAndIndent();
writer.keyword("COMMENT");
getComment().get().unparse(writer, leftPrec, rightPrec);
}
if (location != null) {
writer.newlineAndIndent();
writer.keyword("LOCATION");
location.unparse(writer, leftPrec, rightPrec);
}
if (originPropList.size() > 0) {
writer.keyword("WITH DBPROPERTIES");
SqlWriter.Frame withFrame = writer.startList("(", ")");
for (SqlNode property : originPropList) {
printIndent(writer);
property.unparse(writer, leftPrec, rightPrec);
}
writer.newlineAndIndent();
writer.endList(withFrame);
}
}
use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.sql.SqlWriter in project flink by apache.
the class SqlCreateHiveView method unparse.
@Override
public void unparse(SqlWriter writer, int leftPrec, int rightPrec) {
writer.keyword("CREATE VIEW");
if (isIfNotExists()) {
writer.keyword("IF NOT EXISTS");
}
getViewName().unparse(writer, leftPrec, rightPrec);
if (getFieldList().size() > 0) {
getFieldList().unparse(writer, 1, rightPrec);
}
getComment().ifPresent(c -> {
writer.newlineAndIndent();
writer.keyword("COMMENT");
c.unparse(writer, leftPrec, rightPrec);
});
if (originPropList.size() > 0) {
writer.newlineAndIndent();
writer.keyword("TBLPROPERTIES");
SqlWriter.Frame withFrame = writer.startList("(", ")");
for (SqlNode property : originPropList) {
printIndent(writer);
property.unparse(writer, leftPrec, rightPrec);
}
writer.newlineAndIndent();
writer.endList(withFrame);
}
writer.newlineAndIndent();
writer.keyword("AS");
writer.newlineAndIndent();
getQuery().unparse(writer, leftPrec, rightPrec);
}
use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.sql.SqlWriter in project flink by apache.
the class RichSqlHiveInsert method unparse.
@Override
public void unparse(SqlWriter writer, int leftPrec, int rightPrec) {
writer.startList(SqlWriter.FrameTypeEnum.SELECT);
String insertKeyword = "INSERT INTO";
if (isUpsert()) {
insertKeyword = "UPSERT INTO";
} else if (isOverwrite()) {
insertKeyword = "INSERT OVERWRITE";
}
writer.sep(insertKeyword);
final int opLeft = getOperator().getLeftPrec();
final int opRight = getOperator().getRightPrec();
getTargetTable().unparse(writer, opLeft, opRight);
if (getTargetColumnList() != null) {
getTargetColumnList().unparse(writer, opLeft, opRight);
}
writer.newlineAndIndent();
if (allPartKeys != null && allPartKeys.size() > 0) {
writer.keyword("PARTITION");
SqlWriter.Frame frame = writer.startList("(", ")");
for (SqlNode node : allPartKeys) {
writer.sep(",", false);
SqlIdentifier partKey = (SqlIdentifier) node;
SqlProperty spec = partKeyToSpec.get(partKey);
if (spec != null) {
spec.unparse(writer, leftPrec, rightPrec);
} else {
partKey.unparse(writer, leftPrec, rightPrec);
}
}
writer.endList(frame);
writer.newlineAndIndent();
}
getSource().unparse(writer, 0, 0);
}
use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.sql.SqlWriter in project flink by apache.
the class SqlAlterDatabase method unparse.
@Override
public void unparse(SqlWriter writer, int leftPrec, int rightPrec) {
writer.keyword("ALTER DATABASE");
databaseName.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);
}
use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.sql.SqlWriter in project flink by apache.
the class SqlTableConstraint method unparse.
@Override
public void unparse(SqlWriter writer, int leftPrec, int rightPrec) {
if (this.constraintName != null) {
writer.keyword("CONSTRAINT");
this.constraintName.unparse(writer, leftPrec, rightPrec);
}
this.uniqueSpec.unparse(writer, leftPrec, rightPrec);
if (isTableConstraint) {
SqlWriter.Frame frame = writer.startList("(", ")");
for (SqlNode column : this.columns) {
writer.sep(",", false);
column.unparse(writer, leftPrec, rightPrec);
}
writer.endList(frame);
}
if (this.enforcement != null) {
this.enforcement.unparse(writer, leftPrec, rightPrec);
}
}
Aggregations