本文整理汇总了Java中org.apache.calcite.sql.SqlCall.getKind方法的典型用法代码示例。如果您正苦于以下问题:Java SqlCall.getKind方法的具体用法?Java SqlCall.getKind怎么用?Java SqlCall.getKind使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.calcite.sql.SqlCall
的用法示例。
在下文中一共展示了SqlCall.getKind方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: convertSetOp
import org.apache.calcite.sql.SqlCall; //导入方法依赖的package包/类
/**
* Converts a set operation (UNION, INTERSECT, MINUS) into relational
* expressions.
*
* @param call Call to set operator
* @return Relational expression
*/
protected RelNode convertSetOp(SqlCall call) {
final RelNode left =
convertQueryRecursive(call.operand(0), false, null).project();
final RelNode right =
convertQueryRecursive(call.operand(1), false, null).project();
switch (call.getKind()) {
case UNION:
return LogicalUnion.create(ImmutableList.of(left, right), all(call));
case INTERSECT:
return LogicalIntersect.create(ImmutableList.of(left, right), all(call));
case EXCEPT:
return LogicalMinus.create(ImmutableList.of(left, right), all(call));
default:
throw Util.unexpected(call.getKind());
}
}
示例2: convertSetOp
import org.apache.calcite.sql.SqlCall; //导入方法依赖的package包/类
/**
* Converts a set operation (UNION, INTERSECT, MINUS) into relational
* expressions.
*
* @param call Call to set operator
* @return Relational expression
*/
protected RelNode convertSetOp(SqlCall call) {
final RelNode left =
convertQueryRecursive(call.operand(0), false, null).project();
final RelNode right =
convertQueryRecursive(call.operand(1), false, null).project();
switch (call.getKind()) {
case UNION:
return LogicalUnion.create(ImmutableList.of(left, right), all(call));
case INTERSECT:
return LogicalIntersect.create(ImmutableList.of(left, right), all(call));
case EXCEPT:
return LogicalMinus.create(ImmutableList.of(left, right), all(call));
default:
throw Util.unexpected(call.getKind());
}
}
示例3: visitScoped
import org.apache.calcite.sql.SqlCall; //导入方法依赖的package包/类
@Override protected SqlNode visitScoped(SqlCall call) {
switch (call.getKind()) {
case SCALAR_QUERY:
case CURRENT_VALUE:
case NEXT_VALUE:
case WITH:
return call;
}
// Only visits arguments which are expressions. We don't want to
// qualify non-expressions such as 'x' in 'empno * 5 AS x'.
ArgHandler<SqlNode> argHandler =
new CallCopyingArgHandler(call, false);
call.getOperator().acceptCall(this, call, true, argHandler);
final SqlNode result = argHandler.result();
validator.setOriginal(result, call);
return result;
}
示例4: visit
import org.apache.calcite.sql.SqlCall; //导入方法依赖的package包/类
@Override public SqlNode visit(SqlCall call) {
SqlKind kind = call.getKind();
if (isLogicalNavigation(kind)
|| isAggregation(kind)
|| isRunningOrFinal(kind)) {
return call;
}
switch (kind) {
case PREV:
final List<SqlNode> operands = call.getOperandList();
if (operands.get(0) instanceof SqlIdentifier) {
String name = ((SqlIdentifier) operands.get(0)).names.get(0);
return name.equals(alpha) ? call
: SqlStdOperatorTable.LAST.createCall(SqlParserPos.ZERO, operands);
}
}
return super.visit(call);
}
示例5: unparseCall
import org.apache.calcite.sql.SqlCall; //导入方法依赖的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);
}
}
}
示例6: unparseCall
import org.apache.calcite.sql.SqlCall; //导入方法依赖的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);
}
}
}
示例7: unparseCall
import org.apache.calcite.sql.SqlCall; //导入方法依赖的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);
}
}
示例8: unparseCall
import org.apache.calcite.sql.SqlCall; //导入方法依赖的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);
}
}
示例9: unparseCall
import org.apache.calcite.sql.SqlCall; //导入方法依赖的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);
}
}
示例10: visit
import org.apache.calcite.sql.SqlCall; //导入方法依赖的package包/类
@Override
public List<SqlIdentifier> visit(SqlCall call) {
List<SqlIdentifier> result = new ArrayList<>();
switch (call.getKind()) {
case SELECT:
SqlSelect select = (SqlSelect)call;
SqlNode from = select.getFrom();
result.addAll(extractAncestorsFromFrom(from));
break;
default:
result.addAll(visitAll(call.getOperandList()));
break;
}
return result;
}
示例11: effectiveArgCount
import org.apache.calcite.sql.SqlCall; //导入方法依赖的package包/类
private int effectiveArgCount(SqlCall call) {
switch (call.getKind()) {
case GROUPING:
return call.operandCount();
case GROUP_ID:
return groupExprs.size();
default:
throw new AssertionError(call.getKind());
}
}
示例12: effectiveArgCount
import org.apache.calcite.sql.SqlCall; //导入方法依赖的package包/类
private int effectiveArgCount(SqlCall call) {
switch (call.getKind()) {
case GROUPING:
return call.operandCount();
case GROUP_ID:
return groupExprs.size();
default:
throw new AssertionError(call.getKind());
}
}
示例13: convertFloorCeil
import org.apache.calcite.sql.SqlCall; //导入方法依赖的package包/类
protected RexNode convertFloorCeil(SqlRexContext cx, SqlCall call) {
final boolean floor = call.getKind() == SqlKind.FLOOR;
// Rewrite floor, ceil of interval
if (call.operandCount() == 1
&& call.operand(0) instanceof SqlIntervalLiteral) {
final SqlIntervalLiteral literal = call.operand(0);
SqlIntervalLiteral.IntervalValue interval =
(SqlIntervalLiteral.IntervalValue) literal.getValue();
BigDecimal val =
interval.getIntervalQualifier().getStartUnit().multiplier;
RexNode rexInterval = cx.convertExpression(literal);
final RexBuilder rexBuilder = cx.getRexBuilder();
RexNode zero = rexBuilder.makeExactLiteral(BigDecimal.valueOf(0));
RexNode cond = ge(rexBuilder, rexInterval, zero);
RexNode pad =
rexBuilder.makeExactLiteral(val.subtract(BigDecimal.ONE));
RexNode cast = rexBuilder.makeReinterpretCast(
rexInterval.getType(), pad, rexBuilder.makeLiteral(false));
RexNode sum = floor
? minus(rexBuilder, rexInterval, cast)
: plus(rexBuilder, rexInterval, cast);
RexNode kase = floor
? case_(rexBuilder, rexInterval, cond, sum)
: case_(rexBuilder, sum, cond, rexInterval);
RexNode factor = rexBuilder.makeExactLiteral(val);
RexNode div = divideInt(rexBuilder, kase, factor);
return multiply(rexBuilder, div, factor);
}
// normal floor, ceil function
return convertFunction(cx, (SqlFunction) call.getOperator(), call);
}
示例14: rolledUpColumnValidInsideAgg
import org.apache.calcite.sql.SqlCall; //导入方法依赖的package包/类
@Override public boolean rolledUpColumnValidInsideAgg(String column,
SqlCall call, SqlNode parent,
CalciteConnectionConfig config) {
// For testing
return call.getKind() != SqlKind.MAX
&& (parent.getKind() == SqlKind.SELECT || parent.getKind() == SqlKind.FILTER);
}
示例15: convertOver
import org.apache.calcite.sql.SqlCall; //导入方法依赖的package包/类
private RexNode convertOver(Blackboard bb, SqlNode node) {
SqlCall call = (SqlCall) node;
SqlCall aggCall = call.operand(0);
SqlNode windowOrRef = call.operand(1);
final SqlWindow window =
validator.resolveWindow(windowOrRef, bb.scope, true);
// ROW_NUMBER() expects specific kind of framing.
if (aggCall.getKind() == SqlKind.ROW_NUMBER) {
window.setLowerBound(SqlWindow.createUnboundedPreceding(SqlParserPos.ZERO));
window.setUpperBound(SqlWindow.createCurrentRow(SqlParserPos.ZERO));
window.setRows(SqlLiteral.createBoolean(true, SqlParserPos.ZERO));
}
final SqlNodeList partitionList = window.getPartitionList();
final ImmutableList.Builder<RexNode> partitionKeys =
ImmutableList.builder();
for (SqlNode partition : partitionList) {
partitionKeys.add(bb.convertExpression(partition));
}
RexNode lowerBound = bb.convertExpression(window.getLowerBound());
RexNode upperBound = bb.convertExpression(window.getUpperBound());
SqlNodeList orderList = window.getOrderList();
if ((orderList.size() == 0) && !window.isRows()) {
// A logical range requires an ORDER BY clause. Use the implicit
// ordering of this relation. There must be one, otherwise it would
// have failed validation.
orderList = bb.scope.getOrderList();
if (orderList == null) {
throw new AssertionError(
"Relation should have sort key for implicit ORDER BY");
}
}
final ImmutableList.Builder<RexFieldCollation> orderKeys =
ImmutableList.builder();
final Set<SqlKind> flags = EnumSet.noneOf(SqlKind.class);
for (SqlNode order : orderList) {
flags.clear();
RexNode e = bb.convertSortExpression(order, flags);
orderKeys.add(new RexFieldCollation(e, flags));
}
try {
Preconditions.checkArgument(bb.window == null,
"already in window agg mode");
bb.window = window;
RexNode rexAgg = exprConverter.convertCall(bb, aggCall);
rexAgg =
rexBuilder.ensureType(
validator.getValidatedNodeType(call), rexAgg, false);
// Walk over the tree and apply 'over' to all agg functions. This is
// necessary because the returned expression is not necessarily a call
// to an agg function. For example, AVG(x) becomes SUM(x) / COUNT(x).
final RexShuttle visitor =
new HistogramShuttle(
partitionKeys.build(), orderKeys.build(),
RexWindowBound.create(window.getLowerBound(), lowerBound),
RexWindowBound.create(window.getUpperBound(), upperBound),
window);
return rexAgg.accept(visitor);
} finally {
bb.window = null;
}
}