本文整理汇总了Java中org.apache.calcite.sql.SqlWriter类的典型用法代码示例。如果您正苦于以下问题:Java SqlWriter类的具体用法?Java SqlWriter怎么用?Java SqlWriter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SqlWriter类属于org.apache.calcite.sql包,在下文中一共展示了SqlWriter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: unparse
import org.apache.calcite.sql.SqlWriter; //导入依赖的package包/类
@Override
public void unparse(SqlWriter writer, int leftPrec, int rightPrec) {
writer.keyword("TRAIN");
writer.keyword("MODEL");
mdlName.unparse(writer, leftPrec, rightPrec);
// if (fieldList != null && fieldList.size() > 0) {
// writer.keyword("(");
// fieldList.get(0).unparse(writer, leftPrec, rightPrec);
// for (int i=1; i<fieldList.size(); i++) {
// writer.keyword(",");
// fieldList.get(i).unparse(writer, leftPrec, rightPrec);
// }
// writer.keyword(")");
// }
if (fieldList.size() > 0) {
SqlHandlerUtil.unparseSqlNodeList(writer, leftPrec, rightPrec, fieldList);
}
if (partitionColumns.size() > 0) {
writer.keyword("PARTITION BY");
SqlHandlerUtil.unparseSqlNodeList(writer, leftPrec, rightPrec, partitionColumns);
}
writer.keyword("AS");
query.unparse(writer, leftPrec, rightPrec);
}
示例2: unparse
import org.apache.calcite.sql.SqlWriter; //导入依赖的package包/类
@Override
public void unparse(SqlWriter writer, int leftPrec, int rightPrec) {
writer.keyword("CREATE");
switch (SqlCreateViewType.valueOf(createViewType.toValue())) {
case SIMPLE:
writer.keyword("VIEW");
break;
case OR_REPLACE:
writer.keyword("OR");
writer.keyword("REPLACE");
writer.keyword("VIEW");
break;
case IF_NOT_EXISTS:
writer.keyword("VIEW");
writer.keyword("IF");
writer.keyword("NOT");
writer.keyword("EXISTS");
break;
}
viewName.unparse(writer, leftPrec, rightPrec);
if (fieldList.size() > 0) {
SqlHandlerUtil.unparseSqlNodeList(writer, leftPrec, rightPrec, fieldList);
}
writer.keyword("AS");
query.unparse(writer, leftPrec, rightPrec);
}
示例3: unparse
import org.apache.calcite.sql.SqlWriter; //导入依赖的package包/类
@Override
public void unparse(SqlWriter writer, int leftPrec, int rightPrec) {
writer.keyword("CREATE");
if (isTemporary.booleanValue()) {
writer.keyword("TEMPORARY");
}
writer.keyword("TABLE");
if (tableNonExistenceCheck.booleanValue()) {
writer.keyword("IF");
writer.keyword("NOT");
writer.keyword("EXISTS");
}
tblName.unparse(writer, leftPrec, rightPrec);
if (fieldList.size() > 0) {
SqlHandlerUtil.unparseSqlNodeList(writer, leftPrec, rightPrec, fieldList);
}
if (partitionColumns.size() > 0) {
writer.keyword("PARTITION BY");
SqlHandlerUtil.unparseSqlNodeList(writer, leftPrec, rightPrec, partitionColumns);
}
writer.keyword("AS");
query.unparse(writer, leftPrec, rightPrec);
}
示例4: unparse
import org.apache.calcite.sql.SqlWriter; //导入依赖的package包/类
@Override public void unparse(SqlWriter writer, int leftPrec, int rightPrec) {
name.unparse(writer, 0, 0);
dataType.unparse(writer, 0, 0);
if (dataType.getNullable() != null && !dataType.getNullable()) {
writer.keyword("NOT NULL");
}
if (expression != null) {
switch (strategy) {
case VIRTUAL:
case STORED:
writer.keyword("AS");
exp(writer);
writer.keyword(strategy.name());
break;
case DEFAULT:
writer.keyword("DEFAULT");
exp(writer);
break;
default:
throw new AssertionError("unexpected: " + strategy);
}
}
}
示例5: unparse
import org.apache.calcite.sql.SqlWriter; //导入依赖的package包/类
@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);
}
示例6: unparse
import org.apache.calcite.sql.SqlWriter; //导入依赖的package包/类
@Override public void unparse(SqlWriter writer, int leftPrec, int rightPrec) {
writer.keyword("CREATE");
writer.keyword("MATERIALIZED VIEW");
if (ifNotExists) {
writer.keyword("IF NOT EXISTS");
}
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);
}
示例7: unparse
import org.apache.calcite.sql.SqlWriter; //导入依赖的package包/类
@Override public void unparse(SqlWriter writer, int leftPrec, int rightPrec) {
writer.keyword("CREATE");
writer.keyword("TABLE");
if (ifNotExists) {
writer.keyword("IF NOT EXISTS");
}
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);
}
if (query != null) {
writer.keyword("AS");
writer.newlineAndIndent();
query.unparse(writer, 0, 0);
}
}
示例8: unparseCall
import org.apache.calcite.sql.SqlWriter; //导入依赖的package包/类
@Override public void unparseCall(SqlWriter writer, SqlCall call,
int leftPrec, int rightPrec) {
if (call.getOperator() == SqlStdOperatorTable.SUBSTRING) {
SqlUtil.unparseFunctionSyntax(OracleSqlOperatorTable.SUBSTR, writer, call);
} else {
switch (call.getKind()) {
case FLOOR:
if (call.operandCount() != 2) {
super.unparseCall(writer, call, leftPrec, rightPrec);
return;
}
final SqlLiteral timeUnitNode = call.operand(1);
final TimeUnitRange timeUnit = timeUnitNode.getValueAs(TimeUnitRange.class);
SqlCall call2 = SqlFloorFunction.replaceTimeUnitOperand(call, timeUnit.name(),
timeUnitNode.getParserPosition());
SqlFloorFunction.unparseDatetimeFunction(writer, call2, "TRUNC", true);
break;
default:
super.unparseCall(writer, call, leftPrec, rightPrec);
}
}
}
示例9: unparseCall
import org.apache.calcite.sql.SqlWriter; //导入依赖的package包/类
@Override public void unparseCall(SqlWriter writer, SqlCall call,
int leftPrec, int rightPrec) {
if (call.getOperator() == SqlStdOperatorTable.SUBSTRING) {
if (call.operandCount() != 3) {
throw new IllegalArgumentException("MSSQL SUBSTRING requires FROM and FOR arguments");
}
SqlUtil.unparseFunctionSyntax(MSSQL_SUBSTRING, writer, call);
} else {
switch (call.getKind()) {
case FLOOR:
if (call.operandCount() != 2) {
super.unparseCall(writer, call, leftPrec, rightPrec);
return;
}
unparseFloor(writer, call);
break;
default:
super.unparseCall(writer, call, leftPrec, rightPrec);
}
}
}
示例10: unparseCall
import org.apache.calcite.sql.SqlWriter; //导入依赖的package包/类
@Override public void unparseCall(SqlWriter writer, SqlCall call,
int leftPrec, int rightPrec) {
switch (call.getKind()) {
case FLOOR:
if (call.operandCount() != 2) {
super.unparseCall(writer, call, leftPrec, rightPrec);
return;
}
final SqlLiteral timeUnitNode = call.operand(1);
final TimeUnitRange timeUnit = timeUnitNode.getValueAs(TimeUnitRange.class);
final String translatedLit = convertTimeUnit(timeUnit);
SqlCall call2 = SqlFloorFunction.replaceTimeUnitOperand(call, translatedLit,
timeUnitNode.getParserPosition());
SqlFloorFunction.unparseDatetimeFunction(writer, call2, "TRUNC", true);
break;
default:
super.unparseCall(writer, call, leftPrec, rightPrec);
}
}
示例11: unparseCall
import org.apache.calcite.sql.SqlWriter; //导入依赖的package包/类
@Override public void unparseCall(SqlWriter writer, SqlCall call,
int leftPrec, int rightPrec) {
switch (call.getKind()) {
case FLOOR:
if (call.operandCount() != 2) {
super.unparseCall(writer, call, leftPrec, rightPrec);
return;
}
unparseFloor(writer, call);
break;
default:
super.unparseCall(writer, call, leftPrec, rightPrec);
}
}
示例12: unparseCall
import org.apache.calcite.sql.SqlWriter; //导入依赖的package包/类
@Override public void unparseCall(SqlWriter writer, SqlCall call,
int leftPrec, int rightPrec) {
switch (call.getKind()) {
case FLOOR:
if (call.operandCount() != 2) {
super.unparseCall(writer, call, leftPrec, rightPrec);
return;
}
final SqlLiteral timeUnitNode = call.operand(1);
final TimeUnitRange timeUnit = timeUnitNode.getValueAs(TimeUnitRange.class);
SqlCall call2 = SqlFloorFunction.replaceTimeUnitOperand(call, timeUnit.name(),
timeUnitNode.getParserPosition());
SqlFloorFunction.unparseDatetimeFunction(writer, call2, "DATE_TRUNC", false);
break;
default:
super.unparseCall(writer, call, leftPrec, rightPrec);
}
}
示例13: unparseDatetimeFunction
import org.apache.calcite.sql.SqlWriter; //导入依赖的package包/类
/**
* Most dialects that natively support datetime floor will use this.
* In those cases the call will look like TRUNC(datetime, 'year').
*
* @param writer SqlWriter
* @param call SqlCall
* @param funName Name of the sql function to call
* @param datetimeFirst Specify the order of the datetime & timeUnit
* arguments
*/
public static void unparseDatetimeFunction(SqlWriter writer, SqlCall call,
String funName, Boolean datetimeFirst) {
SqlFunction func = new SqlFunction(funName, SqlKind.OTHER_FUNCTION,
ReturnTypes.ARG0_NULLABLE_VARYING, null, null,
SqlFunctionCategory.STRING);
SqlCall call1;
if (datetimeFirst) {
call1 = call;
} else {
// switch order of operands
SqlNode op1 = call.operand(0);
SqlNode op2 = call.operand(1);
call1 = call.getOperator().createCall(call.getParserPosition(), op2, op1);
}
SqlUtil.unparseFunctionSyntax(func, writer, call1);
}
示例14: unparse
import org.apache.calcite.sql.SqlWriter; //导入依赖的package包/类
public void unparse(
SqlWriter writer,
SqlCall call,
int leftPrec,
int rightPrec) {
final SqlWriter.Frame frame = writer.startFunCall(getName());
call.operand(0).unparse(writer, leftPrec, rightPrec);
writer.sep("FROM");
call.operand(1).unparse(writer, leftPrec, rightPrec);
if (3 == call.operandCount()) {
writer.sep("FOR");
call.operand(2).unparse(writer, leftPrec, rightPrec);
}
writer.endFunCall(frame);
}
示例15: unparse
import org.apache.calcite.sql.SqlWriter; //导入依赖的package包/类
public void unparse(
SqlWriter writer,
SqlCall call,
int leftPrec,
int rightPrec) {
final SqlWriter.Frame frame = writer.startList("", "");
call.operand(0).unparse(writer, getLeftPrec(), getRightPrec());
writer.sep(getName());
call.operand(1).unparse(writer, getLeftPrec(), getRightPrec());
if (call.operandCount() == 3) {
writer.sep("ESCAPE");
call.operand(2).unparse(writer, getLeftPrec(), getRightPrec());
}
writer.endList(frame);
}