private static boolean canConvert(RelDataType fromType, RelDataType toType) { return SqlTypeUtil.canAssignFrom(toType, fromType); }
private static boolean canConvert(RelDataType fromType, RelDataType toType) { return SqlTypeUtil.canAssignFrom(toType, fromType); }
/** * @sql.99 Part 2 Section 10.4 Syntax Rule 6.b.iii.2.B */ private static void filterRoutinesByParameterType( List<SqlFunction> routines, List<RelDataType> argTypes) { Iterator<SqlFunction> iter = routines.iterator(); while (iter.hasNext()) { SqlFunction function = iter.next(); List<RelDataType> paramTypes = function.getParamTypes(); if (paramTypes == null) { // no parameter information for builtins; keep for now continue; } assert paramTypes.size() == argTypes.size(); boolean keep = true; for (Pair<RelDataType, RelDataType> p : Pair.zip(paramTypes, argTypes)) { final RelDataType argType = p.right; final RelDataType paramType = p.left; if (!SqlTypeUtil.canAssignFrom(paramType, argType)) { keep = false; break; } } if (!keep) { iter.remove(); } } }
/** * Sets a finite value for this endpoint. * * @param boundType bound type (upper/lower) * @param strictness boundary strictness * @param coordinate endpoint position */ void setFinite( SargBoundType boundType, SargStrictness strictness, RexNode coordinate) { // validate the input assert (coordinate != null); if (!(coordinate instanceof RexDynamicParam) && !(coordinate instanceof RexInputRef)) { assert (coordinate instanceof RexLiteral); RexLiteral literal = (RexLiteral) coordinate; if (!RexLiteral.isNullLiteral(literal)) { assert (SqlTypeUtil.canAssignFrom( dataType, literal.getType())); } } this.boundType = boundType; this.coordinate = coordinate; this.strictness = strictness; convertToTargetType(); }
/** * Sets a finite value for this endpoint. * * @param boundType bound type (upper/lower) * @param strictness boundary strictness * @param coordinate endpoint position */ void setFinite( SargBoundType boundType, SargStrictness strictness, RexNode coordinate) { // validate the input assert coordinate != null; if (!(coordinate instanceof RexDynamicParam) && !(coordinate instanceof RexInputRef)) { assert coordinate instanceof RexLiteral; RexLiteral literal = (RexLiteral) coordinate; if (!RexLiteral.isNullLiteral(literal)) { assert SqlTypeUtil.canAssignFrom( dataType, literal.getType()); } } this.boundType = boundType; this.coordinate = coordinate; this.strictness = strictness; convertToTargetType(); }
/** * @return true if all tuples match rowType; otherwise, assert on mismatch */ private boolean assertRowType() { for (List<RexLiteral> tuple : tuples) { assert tuple.size() == rowType.getFieldCount(); for (Pair<RexLiteral, RelDataTypeField> pair : Pair.zip(tuple, rowType.getFieldList())) { RexLiteral literal = pair.left; RelDataType fieldType = pair.right.getType(); // TODO jvs 19-Feb-2006: strengthen this a bit. For example, // overflow, rounding, and padding/truncation must already have // been dealt with. if (!RexLiteral.isNullLiteral(literal)) { assert SqlTypeUtil.canAssignFrom(fieldType, literal.getType()) : "to " + fieldType + " from " + literal; } } } return true; }
/** * @return true if all tuples match rowType; otherwise, assert on mismatch */ private boolean assertRowType() { for (List<RexLiteral> tuple : tuples) { assert tuple.size() == rowType.getFieldCount(); for (Pair<RexLiteral, RelDataTypeField> pair : Pair.zip(tuple, rowType.getFieldList())) { RexLiteral literal = pair.left; RelDataType fieldType = pair.right.getType(); // TODO jvs 19-Feb-2006: strengthen this a bit. For example, // overflow, rounding, and padding/truncation must already have // been dealt with. if (!RexLiteral.isNullLiteral(literal)) { assert (SqlTypeUtil.canAssignFrom( fieldType, literal.getType())); } } } return true; }
RelDataType sourceType = sourceFields.get(i).getType(); RelDataType targetType = targetFields.get(i).getType(); if (!SqlTypeUtil.canAssignFrom(targetType, sourceType)) {
RelDataType sourceType = sourceFields.get(i).getType(); RelDataType targetType = targetFields.get(i).getType(); if (!SqlTypeUtil.canAssignFrom(targetType, sourceType)) {
public boolean checkOperandTypes( SqlCallBinding callBinding, boolean throwOnFailure) { for (int i = 0; i < callBinding.getOperandCount(); ++i) { RelDataType argType = callBinding.getValidator().deriveType( callBinding.getScope(), callBinding.getCall().operands[i]); if (!SqlTypeUtil.canAssignFrom(paramTypes[i], argType)) { if (throwOnFailure) { throw callBinding.newValidationSignatureError(); } else { return false; } } } return true; }
public boolean checkOperandTypes( SqlCallBinding callBinding, boolean throwOnFailure) { final List<SqlNode> operands = callBinding.getCall().getOperandList(); for (Pair<RelDataType, SqlNode> pair : Pair.zip(paramTypes, operands)) { RelDataType argType = callBinding.getValidator().deriveType( callBinding.getScope(), pair.right); if (!SqlTypeUtil.canAssignFrom(pair.left, argType)) { if (throwOnFailure) { throw callBinding.newValidationSignatureError(); } else { return false; } } } return true; }