/** * @return true if type is numeric */ public static boolean isNumeric(RelDataType type) { return isExactNumeric(type) || isApproximateNumeric(type); }
/** * @return true if type is numeric */ public static boolean isNumeric(RelDataType type) { return isExactNumeric(type) || isApproximateNumeric(type); }
/** * @return true if type is numeric */ public static boolean isNumeric(RelDataType type) { return isExactNumeric(type) || isApproximateNumeric(type); }
/** * Convenience method for reading characteristics of operands (such as * scale, precision, whole digits) into an ArithmeticExpander. The * operands are restricted by the following contraints: * * <ul> * <li>there are exactly two operands * <li>both are exact numeric types * </ul> */ private void analyzeOperands(List<RexNode> operands) { assert operands.size() == 2; typeA = operands.get(0).getType(); typeB = operands.get(1).getType(); assert SqlTypeUtil.isExactNumeric(typeA) && SqlTypeUtil.isExactNumeric(typeB); scaleA = typeA.getScale(); scaleB = typeB.getScale(); }
/** * Convenience method for reading characteristics of operands (such as * scale, precision, whole digits) into an ArithmeticExpander. The * operands are restricted by the following contraints: * * <ul> * <li>there are exactly two operands * <li>both are exact numeric types * </ul> */ private void analyzeOperands(List<RexNode> operands) { assert operands.size() == 2; typeA = operands.get(0).getType(); typeB = operands.get(1).getType(); assert SqlTypeUtil.isExactNumeric(typeA) && SqlTypeUtil.isExactNumeric(typeB); scaleA = typeA.getScale(); scaleB = typeB.getScale(); }
/** * Returns the type for a histogram function. It is either the actual * type or an an approximation to it. */ private RelDataType computeHistogramType(RelDataType type) { if (SqlTypeUtil.isExactNumeric(type) && type.getSqlTypeName() != SqlTypeName.BIGINT) { return typeFactory.createSqlType(SqlTypeName.BIGINT); } else if (SqlTypeUtil.isApproximateNumeric(type) && type.getSqlTypeName() != SqlTypeName.DOUBLE) { return typeFactory.createSqlType(SqlTypeName.DOUBLE); } else { return type; } } }
RelDataType type1, RelDataType type2) { if (SqlTypeUtil.isExactNumeric(type1) && SqlTypeUtil.isExactNumeric(type2)) { if (SqlTypeUtil.isDecimal(type1) || SqlTypeUtil.isDecimal(type2)) {
RelDataType type1, RelDataType type2) { if (SqlTypeUtil.isExactNumeric(type1) && SqlTypeUtil.isExactNumeric(type2)) { if (SqlTypeUtil.isDecimal(type1) || SqlTypeUtil.isDecimal(type2)) {
@Override public RexNode makeCast( RelDataType type, RexNode exp, boolean matchNullability) { // Special case: bypassing Calcite for interval types if (!(exp instanceof RexLiteral) && SqlTypeUtil.isExactNumeric(type) && SqlTypeUtil.isInterval(exp.getType())) { return makeAbstractCast(type, exp); } RexNode castRexNode = super.makeCast(type, exp, matchNullability); // If we have a CAST(A, TYPE) and A is already of the same TYPE (including nullability), // then return just A. if (castRexNode instanceof RexCall && castRexNode.getKind() == SqlKind.CAST && castRexNode.getType().equals(((RexCall) castRexNode).getOperands().get(0).getType())) { return ((RexCall) castRexNode).getOperands().get(0); } return castRexNode; } }
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); } }
/** * Returns the type for a histogram function. It is either the actual * type or an an approximation to it. */ private RelDataType computeHistogramType(RelDataType type) { if (SqlTypeUtil.isExactNumeric(type) && type.getSqlTypeName() != SqlTypeName.BIGINT) { return typeFactory.createSqlType(SqlTypeName.BIGINT); } else if (SqlTypeUtil.isApproximateNumeric(type) && type.getSqlTypeName() != SqlTypeName.DOUBLE) { return typeFactory.createSqlType(SqlTypeName.DOUBLE); } else { return type; } } }
/** * Returns the type for a histogram function. It is either the actual * type or an an approximation to it. */ private RelDataType computeHistogramType(RelDataType type) { if (SqlTypeUtil.isExactNumeric(type) && type.getSqlTypeName() != SqlTypeName.BIGINT) { return typeFactory.createSqlType(SqlTypeName.BIGINT); } else if (SqlTypeUtil.isApproximateNumeric(type) && type.getSqlTypeName() != SqlTypeName.DOUBLE) { return typeFactory.createSqlType(SqlTypeName.DOUBLE); } else { return type; } } }
RelDataType type1, RelDataType type2) { if (SqlTypeUtil.isExactNumeric(type1) && SqlTypeUtil.isExactNumeric(type2)) { if (SqlTypeUtil.isDecimal(type1) || SqlTypeUtil.isDecimal(type2)) {
/** * Returns the type for a histogram function. It is either the actual * type or an an approximation to it. */ private RelDataType computeHistogramType(RelDataType type) { if (SqlTypeUtil.isExactNumeric(type) && type.getSqlTypeName() != SqlTypeName.BIGINT) { return typeFactory.createSqlType(SqlTypeName.BIGINT); } else if (SqlTypeUtil.isApproximateNumeric(type) && type.getSqlTypeName() != SqlTypeName.DOUBLE) { return typeFactory.createSqlType(SqlTypeName.DOUBLE); } else { return type; } } }
RelDataType type1, RelDataType type2) { if (SqlTypeUtil.isExactNumeric(type1) && SqlTypeUtil.isExactNumeric(type2)) { if (SqlTypeUtil.isDecimal(type1) || SqlTypeUtil.isDecimal(type2)) {
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); } }
if (SqlTypeUtil.isExactNumeric(type) && SqlTypeUtil.hasScale(type)) { BigDecimal roundedValue = NumberUtil.rescaleBigDecimal(
if (SqlTypeUtil.isExactNumeric(type) && SqlTypeUtil.hasScale(type)) { BigDecimal roundedValue = NumberUtil.rescaleBigDecimal(
if (SqlTypeUtil.isExactNumeric(type) && SqlTypeUtil.hasScale(type)) { BigDecimal roundedValue = NumberUtil.rescaleBigDecimal(
if (SqlTypeUtil.isExactNumeric(type) && SqlTypeUtil.hasScale(type)) { BigDecimal roundedValue = NumberUtil.rescaleBigDecimal(