/** * Retrieves a decimal node's integer representation * * @param decimalNode the decimal value as an opaque type * @return an integer representation of the decimal value */ protected RexNode decodeValue(RexNode decimalNode) { assert SqlTypeUtil.isDecimal(decimalNode.getType()); return builder.decodeIntervalOrDecimal(decimalNode); }
/** * Retrieves a decimal node's integer representation * * @param decimalNode the decimal value as an opaque type * @return an integer representation of the decimal value */ protected RexNode decodeValue(RexNode decimalNode) { assert SqlTypeUtil.isDecimal(decimalNode.getType()); return builder.decodeIntervalOrDecimal(decimalNode); }
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; } }
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; } }
/** * Retrieves the primitive value of a numeric node. If the node is a * decimal, then it must first be decoded. Otherwise the original node * may be returned. * * @param node a numeric node, possibly a decimal * @return the primitive value of the numeric node */ protected RexNode accessValue(RexNode node) { assert SqlTypeUtil.isNumeric(node.getType()); if (SqlTypeUtil.isDecimal(node.getType())) { return decodeValue(node); } return node; }
/** * Retrieves the primitive value of a numeric node. If the node is a * decimal, then it must first be decoded. Otherwise the original node * may be returned. * * @param node a numeric node, possibly a decimal * @return the primitive value of the numeric node */ protected RexNode accessValue(RexNode node) { assert SqlTypeUtil.isNumeric(node.getType()); if (SqlTypeUtil.isDecimal(node.getType())) { return decodeValue(node); } return node; }
public RexNode expand(RexCall call) { ImmutableList.Builder<RexNode> opBuilder = ImmutableList.builder(); for (RexNode operand : call.operands) { if (SqlTypeUtil.isNumeric(operand.getType())) { opBuilder.add(accessValue(operand)); } else { opBuilder.add(operand); } } RexNode newCall = builder.makeCall(call.getType(), call.getOperator(), opBuilder.build()); if (SqlTypeUtil.isDecimal(call.getType())) { return encodeValue( newCall, call.getType()); } else { return newCall; } } }
public RexNode expand(RexCall call) { ImmutableList.Builder<RexNode> opBuilder = ImmutableList.builder(); for (RexNode operand : call.operands) { if (SqlTypeUtil.isNumeric(operand.getType())) { opBuilder.add(accessValue(operand)); } else { opBuilder.add(operand); } } RexNode newCall = builder.makeCall(call.getType(), call.getOperator(), opBuilder.build()); if (SqlTypeUtil.isDecimal(call.getType())) { return encodeValue( newCall, call.getType()); } else { return newCall; } } }
public RexNode expand(RexCall call) { ImmutableList.Builder<RexNode> opBuilder = ImmutableList.builder(); for (Ord<RexNode> operand : Ord.zip(call.operands)) { RelDataType targetType = getArgType(call, operand.i); if (SqlTypeUtil.isDecimal(operand.e.getType())) { opBuilder.add(ensureType(targetType, operand.e, true)); } else { opBuilder.add(operand.e); } } RexNode ret = builder.makeCall( call.getType(), call.getOperator(), opBuilder.build()); ret = ensureType( call.getType(), ret, true); return ret; } }
public RexNode expand(RexCall call) { ImmutableList.Builder<RexNode> opBuilder = ImmutableList.builder(); for (Ord<RexNode> operand : Ord.zip(call.operands)) { RelDataType targetType = getArgType(call, operand.i); if (SqlTypeUtil.isDecimal(operand.e.getType())) { opBuilder.add(ensureType(targetType, operand.e, true)); } else { opBuilder.add(operand.e); } } RexNode ret = builder.makeCall( call.getType(), call.getOperator(), opBuilder.build()); ret = ensureType( call.getType(), ret, true); return ret; } }
/** * Retrieves an interval or decimal node's integer representation * * @param node the interval or decimal value as an opaque type * @return an integer representation of the decimal value */ public RexNode decodeIntervalOrDecimal(RexNode node) { assert SqlTypeUtil.isDecimal(node.getType()) || SqlTypeUtil.isInterval(node.getType()); RelDataType bigintType = typeFactory.createSqlType(SqlTypeName.BIGINT); return makeReinterpretCast( matchNullability(bigintType, node), node, makeLiteral(false)); }
/** * Retrieves an interval or decimal node's integer representation * * @param node the interval or decimal value as an opaque type * @return an integer representation of the decimal value */ public RexNode decodeIntervalOrDecimal(RexNode node) { assert SqlTypeUtil.isDecimal(node.getType()) || SqlTypeUtil.isInterval(node.getType()); RelDataType bigintType = typeFactory.createSqlType(SqlTypeName.BIGINT); return makeReinterpretCast( matchNullability(bigintType, node), node, makeLiteral(false)); }
private RexNode expandMod(RexCall call, List<RexNode> operands) { assert SqlTypeUtil.isExactNumeric(typeA); assert SqlTypeUtil.isExactNumeric(typeB); if (scaleA != 0 || scaleB != 0) { throw RESOURCE.argumentMustHaveScaleZero(call.getOperator().getName()) .ex(); } RexNode result = builder.makeCall( call.getOperator(), accessValue(operands.get(0)), accessValue(operands.get(1))); RelDataType retType = call.getType(); if (SqlTypeUtil.isDecimal(retType)) { return encodeValue(result, retType); } return ensureType( call.getType(), result); } }
private RexNode expandMod(RexCall call, List<RexNode> operands) { assert SqlTypeUtil.isExactNumeric(typeA); assert SqlTypeUtil.isExactNumeric(typeB); if (scaleA != 0 || scaleB != 0) { throw RESOURCE.argumentMustHaveScaleZero(call.getOperator().getName()) .ex(); } RexNode result = builder.makeCall( call.getOperator(), accessValue(operands.get(0)), accessValue(operands.get(1))); RelDataType retType = call.getType(); if (SqlTypeUtil.isDecimal(retType)) { return encodeValue(result, retType); } return ensureType( call.getType(), result); } }