本文整理汇总了Java中org.apache.calcite.sql.SqlWriter类的典型用法代码示例。如果您正苦于以下问题:Java SqlWriter类的具体用法?Java SqlWriter怎么用?Java SqlWriter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SqlWriter类属于org.apache.calcite.sql包,在下文中一共展示了SqlWriter类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
开发者ID:skhalifa,项目名称:QDrill,代码行数:26,代码来源:SqlTrainModel.java
示例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);
}
开发者ID:axbaretto,项目名称:drill,代码行数:27,代码来源:SqlCreateView.java
示例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);
}
开发者ID:axbaretto,项目名称:drill,代码行数:24,代码来源:SqlCreateTable.java
示例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);
}
}
}
开发者ID:apache,项目名称:calcite,代码行数:24,代码来源:SqlColumnDeclaration.java
示例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);
}
开发者ID:apache,项目名称:calcite,代码行数:21,代码来源:SqlCreateView.java
示例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);
}
开发者ID:apache,项目名称:calcite,代码行数:20,代码来源:SqlCreateMaterializedView.java
示例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);
}
}
开发者ID:apache,项目名称:calcite,代码行数:22,代码来源:SqlCreateTable.java
示例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);
}
}
}
开发者ID:apache,项目名称:calcite,代码行数:26,代码来源:OracleSqlDialect.java
示例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);
}
}
}
开发者ID:apache,项目名称:calcite,代码行数:23,代码来源:MssqlSqlDialect.java
示例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);
}
}
开发者ID:apache,项目名称:calcite,代码行数:23,代码来源:HsqldbSqlDialect.java
示例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);
}
}
开发者ID:apache,项目名称:calcite,代码行数:17,代码来源:MysqlSqlDialect.java
示例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);
}
}
开发者ID:apache,项目名称:calcite,代码行数:22,代码来源:PostgresqlSqlDialect.java
示例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);
}
开发者ID:apache,项目名称:calcite,代码行数:30,代码来源:SqlFloorFunction.java
示例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);
}
开发者ID:apache,项目名称:calcite,代码行数:18,代码来源:SqlSubstringFunction.java
示例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);
}
开发者ID:apache,项目名称:calcite,代码行数:17,代码来源:SqlLikeOperator.java
示例16: unparseCube
import org.apache.calcite.sql.SqlWriter; //导入依赖的package包/类
private static void unparseCube(SqlWriter writer, SqlCall call) {
writer.keyword(call.getOperator().getName());
final SqlWriter.Frame frame =
writer.startList(SqlWriter.FrameTypeEnum.FUN_CALL, "(", ")");
for (SqlNode operand : call.getOperandList()) {
writer.sep(",");
if (operand.getKind() == SqlKind.ROW) {
final SqlWriter.Frame frame2 =
writer.startList(SqlWriter.FrameTypeEnum.SIMPLE, "(", ")");
for (SqlNode operand2 : ((SqlCall) operand).getOperandList()) {
writer.sep(",");
operand2.unparse(writer, 0, 0);
}
writer.endList(frame2);
} else if (operand instanceof SqlNodeList
&& ((SqlNodeList) operand).size() == 0) {
writer.keyword("()");
} else {
operand.unparse(writer, 0, 0);
}
}
writer.endList(frame);
}
开发者ID:apache,项目名称:calcite,代码行数:24,代码来源:SqlRollupOperator.java
示例17: unparse
import org.apache.calcite.sql.SqlWriter; //导入依赖的package包/类
@Override public void unparse(SqlWriter writer, SqlCall call, int leftPrec,
int rightPrec) {
final SqlOperator operator = call.getOperator();
assert call.operandCount() == 2;
final SqlWriter.Frame frame =
writer.startList(SqlWriter.FrameTypeEnum.SIMPLE);
call.operand(0).unparse(writer, leftPrec, operator.getLeftPrec());
writer.setNeedWhitespace(true);
writer.sep(operator.getName());
final SqlNodeList list = call.operand(1);
final SqlWriter.Frame frame2 = writer.startList("(", ")");
for (Ord<SqlNode> node2 : Ord.zip(list)) {
if (node2.i > 0 && node2.i % 2 == 0) {
writer.sep(",");
}
node2.e.unparse(writer, 2, 3);
}
writer.endList(frame2);
writer.endList(frame);
}
开发者ID:apache,项目名称:calcite,代码行数:21,代码来源:SqlExtendOperator.java
示例18: unparse
import org.apache.calcite.sql.SqlWriter; //导入依赖的package包/类
@Override public void unparse(SqlWriter writer, SqlCall call_, int leftPrec,
int rightPrec) {
SqlCase kase = (SqlCase) call_;
final SqlWriter.Frame frame =
writer.startList(FRAME_TYPE, "CASE", "END");
assert kase.whenList.size() == kase.thenList.size();
if (kase.value != null) {
kase.value.unparse(writer, 0, 0);
}
for (Pair<SqlNode, SqlNode> pair : Pair.zip(kase.whenList, kase.thenList)) {
writer.sep("WHEN");
pair.left.unparse(writer, 0, 0);
writer.sep("THEN");
pair.right.unparse(writer, 0, 0);
}
writer.sep("ELSE");
kase.elseExpr.unparse(writer, 0, 0);
writer.endList(frame);
}
开发者ID:apache,项目名称:calcite,代码行数:21,代码来源:SqlCaseOperator.java
示例19: 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("PLACING");
call.operand(1).unparse(writer, leftPrec, rightPrec);
writer.sep("FROM");
call.operand(2).unparse(writer, leftPrec, rightPrec);
if (4 == call.operandCount()) {
writer.sep("FOR");
call.operand(3).unparse(writer, leftPrec, rightPrec);
}
writer.endFunCall(frame);
}
开发者ID:apache,项目名称:calcite,代码行数:18,代码来源:SqlOverlayFunction.java
示例20: unparse
import org.apache.calcite.sql.SqlWriter; //导入依赖的package包/类
@Override
public void unparse(SqlWriter writer, int leftPrec, int rightPrec) {
UnparseUtil u = new UnparseUtil(writer, leftPrec, rightPrec);
u.keyword("CREATE", "FUNCTION");
if (dbName != null) {
u.node(dbName).keyword(".");
}
u.node(funcName).keyword("AS").node(className);
if (jarList != null) {
u.keyword("USING").nodeList(jarList);
}
}
开发者ID:uber,项目名称:AthenaX,代码行数:13,代码来源:SqlCreateFunction.java
注:本文中的org.apache.calcite.sql.SqlWriter类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论