本文整理汇总了Java中org.apache.calcite.rex.RexCall.getType方法的典型用法代码示例。如果您正苦于以下问题:Java RexCall.getType方法的具体用法?Java RexCall.getType怎么用?Java RexCall.getType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.calcite.rex.RexCall
的用法示例。
在下文中一共展示了RexCall.getType方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: expandPlusMinus
import org.apache.calcite.rex.RexCall; //导入方法依赖的package包/类
private RexNode expandPlusMinus(RexCall call, List<RexNode> operands) {
RelDataType outType = call.getType();
int outScale = outType.getScale();
return encodeValue(
builder.makeCall(
call.getOperator(),
ensureScale(
accessValue(operands.get(0)),
scaleA,
outScale),
ensureScale(
accessValue(operands.get(1)),
scaleB,
outScale)),
outType);
}
示例2: expandDivide
import org.apache.calcite.rex.RexCall; //导入方法依赖的package包/类
private RexNode expandDivide(RexCall call, List<RexNode> operands) {
RelDataType outType = call.getType();
RexNode dividend =
builder.makeCall(
call.getOperator(),
ensureType(
real8,
accessValue(operands.get(0))),
ensureType(
real8,
accessValue(operands.get(1))));
int scaleDifference = outType.getScale() - scaleA + scaleB;
RexNode rescale =
builder.makeCall(
SqlStdOperatorTable.MULTIPLY,
dividend,
makeApproxScaleFactor(scaleDifference));
return encodeValue(rescale, outType);
}
示例3: expand
import org.apache.calcite.rex.RexCall; //导入方法依赖的package包/类
public RexNode expand(RexCall call) {
RelDataType retType = call.getType();
int argCount = call.operands.size();
ImmutableList.Builder<RexNode> opBuilder = ImmutableList.builder();
for (int i = 0; i < argCount; i++) {
// skip case conditions
if (((i % 2) == 0) && (i != (argCount - 1))) {
opBuilder.add(call.operands.get(i));
continue;
}
RexNode expr = ensureType(retType, call.operands.get(i), false);
if (SqlTypeUtil.isDecimal(retType)) {
expr = decodeValue(expr);
}
opBuilder.add(expr);
}
RexNode newCall =
builder.makeCall(retType, call.getOperator(), opBuilder.build());
if (SqlTypeUtil.isDecimal(retType)) {
newCall = encodeValue(newCall, retType);
}
return newCall;
}
示例4: visitCall
import org.apache.calcite.rex.RexCall; //导入方法依赖的package包/类
@Override
public RexNode visitCall(RexCall call) {
SqlOperator op = call.getOperator();
SqlKind kind = op.getKind();
RelDataType type = call.getType();
if (kind == SqlKind.OR || kind == SqlKind.AND) {
if (call.getOperands().size() > 2) {
List<RexNode> children = new ArrayList(call.getOperands());
RexNode left = children.remove(0).accept(this);
RexNode right = builder.makeCall(type, op, children).accept(this);
return builder.makeCall(type, op, ImmutableList.of(left, right));
}
}
return builder.makeCall(type, op, visitChildren(call));
}
示例5: visitCall
import org.apache.calcite.rex.RexCall; //导入方法依赖的package包/类
@Override
public RexNode visitCall(RexCall call) {
SqlOperator op = call.getOperator();
SqlKind kind = op.getKind();
RelDataType type = call.getType();
if (kind == SqlKind.OR || kind == SqlKind.AND) {
if (call.getOperands().size() > 2) {
List<RexNode> children = new ArrayList<>(call.getOperands());
RexNode left = children.remove(0).accept(this);
RexNode right = builder.makeCall(type, op, children).accept(this);
return builder.makeCall(type, op, ImmutableList.of(left, right));
}
}
return builder.makeCall(type, op, visitChildren(call));
}
示例6: reduceCasts
import org.apache.calcite.rex.RexCall; //导入方法依赖的package包/类
private void reduceCasts(RexCall outerCast) {
List<RexNode> operands = outerCast.getOperands();
if (operands.size() != 1) {
return;
}
RelDataType outerCastType = outerCast.getType();
RelDataType operandType = operands.get(0).getType();
if (operandType.equals(outerCastType)) {
removableCasts.add(outerCast);
return;
}
// See if the reduction
// CAST((CAST x AS type) AS type NOT NULL)
// -> CAST(x AS type NOT NULL)
// applies. TODO jvs 15-Dec-2008: consider
// similar cases for precision changes.
if (!(operands.get(0) instanceof RexCall)) {
return;
}
RexCall innerCast = (RexCall) operands.get(0);
if (innerCast.getOperator() != SqlStdOperatorTable.CAST) {
return;
}
if (innerCast.getOperands().size() != 1) {
return;
}
RelDataType outerTypeNullable =
typeFactory.createTypeWithNullability(outerCastType, true);
RelDataType innerTypeNullable =
typeFactory.createTypeWithNullability(operandType, true);
if (outerTypeNullable != innerTypeNullable) {
return;
}
if (operandType.isNullable()) {
removableCasts.add(innerCast);
}
}
示例7: canSimplify
import org.apache.calcite.rex.RexCall; //导入方法依赖的package包/类
/**
* Detect, in a generic, but strict way, whether it is possible to
* simplify a reinterpret cast. The rules are as follows:
*
* <ol>
* <li>If value is not the same basic type as outer, then we cannot
* simplify
* <li>If the value is nullable but the inner or outer are not, then we
* cannot simplify.
* <li>If inner is nullable but outer is not, we cannot simplify.
* <li>If an overflow check is required from either inner or outer, we
* cannot simplify.
* <li>Otherwise, given the same type, and sufficient nullability
* constraints, we can simplify.
* </ol>
*
* @param outer outer call to reinterpret
* @param inner inner call to reinterpret
* @param value inner value
* @return whether the two reinterpret casts can be removed
*/
private boolean canSimplify(
RexCall outer,
RexCall inner,
RexNode value) {
RelDataType outerType = outer.getType();
RelDataType innerType = inner.getType();
RelDataType valueType = value.getType();
boolean outerCheck = RexUtil.canReinterpretOverflow(outer);
boolean innerCheck = RexUtil.canReinterpretOverflow(inner);
if ((outerType.getSqlTypeName() != valueType.getSqlTypeName())
|| (outerType.getPrecision() != valueType.getPrecision())
|| (outerType.getScale() != valueType.getScale())) {
return false;
}
if (valueType.isNullable()
&& (!innerType.isNullable() || !outerType.isNullable())) {
return false;
}
if (innerType.isNullable() && !outerType.isNullable()) {
return false;
}
// One would think that we could go from Nullable -> Not Nullable
// since we are substituting a general type with a more specific
// type. However the optimizer doesn't like it.
if (valueType.isNullable() != outerType.isNullable()) {
return false;
}
if (innerCheck || outerCheck) {
return false;
}
return true;
}
示例8: visitCall
import org.apache.calcite.rex.RexCall; //导入方法依赖的package包/类
@Override
public RexNode visitCall(final RexCall call) {
RexNode newCall;
boolean[] update = {false};
List<RexNode> clonedOperands = visitList(call.operands, update);
if (update[0]) {
SqlOperator operator = call.getOperator();
boolean isSpecialCast = false;
if (operator instanceof SqlFunction) {
SqlFunction function = (SqlFunction) operator;
if (function.getKind() == SqlKind.CAST) {
if (call.operands.size() < 2) {
isSpecialCast = true;
}
}
}
final RelDataType newType;
if (!isSpecialCast) {
// TODO: ideally this only needs to be called if the result
// type will also change. However, since that requires
// support from type inference rules to tell whether a rule
// decides return type based on input types, for now all
// operators will be recreated with new type if any operand
// changed, unless the operator has "built-in" type.
newType = rexBuilder.deriveReturnType(operator, clonedOperands);
} else {
// Use the current return type when creating a new call, for
// operators with return type built into the operator
// definition, and with no type inference rules, such as
// cast function with less than 2 operands.
// TODO: Comments in RexShuttle.visitCall() mention other
// types in this category. Need to resolve those together
// and preferably in the base class RexShuttle.
newType = call.getType();
}
newCall = rexBuilder.makeCall(newType, operator, clonedOperands);
} else {
newCall = call;
}
if (projectPulledAboveLeftCorrelator && (nullIndicator != null)) {
return createCaseExpression(nullIndicator, rexBuilder.constantNull(), newCall);
}
return newCall;
}
示例9: visitCall
import org.apache.calcite.rex.RexCall; //导入方法依赖的package包/类
@Override public RexNode visitCall(final RexCall call) {
RexNode newCall;
boolean[] update = {false};
List<RexNode> clonedOperands = visitList(call.operands, update);
if (update[0]) {
SqlOperator operator = call.getOperator();
boolean isSpecialCast = false;
if (operator instanceof SqlFunction) {
SqlFunction function = (SqlFunction) operator;
if (function.getKind() == SqlKind.CAST) {
if (call.operands.size() < 2) {
isSpecialCast = true;
}
}
}
final RelDataType newType;
if (!isSpecialCast) {
// TODO: ideally this only needs to be called if the result
// type will also change. However, since that requires
// support from type inference rules to tell whether a rule
// decides return type based on input types, for now all
// operators will be recreated with new type if any operand
// changed, unless the operator has "built-in" type.
newType = rexBuilder.deriveReturnType(operator, clonedOperands);
} else {
// Use the current return type when creating a new call, for
// operators with return type built into the operator
// definition, and with no type inference rules, such as
// cast function with less than 2 operands.
// TODO: Comments in RexShuttle.visitCall() mention other
// types in this category. Need to resolve those together
// and preferably in the base class RexShuttle.
newType = call.getType();
}
newCall =
rexBuilder.makeCall(
newType,
operator,
clonedOperands);
} else {
newCall = call;
}
if (projectPulledAboveLeftCorrelator && (nullIndicator != null)) {
return createCaseExpression(
nullIndicator,
rexBuilder.constantNull(),
newCall);
}
return newCall;
}