RelDataType sourceType = sourceFields.get(i).getType(); RelDataType targetType = targetFields.get(i).getType(); if (!SqlTypeUtil.canAssignFrom(targetType, sourceType)) {
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); }
private static void verifyRowType(final ImmutableList<ImmutableList<RexLiteral>> tuples, RelDataType rowType){ 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(); if ((!(RexLiteral.isNullLiteral(literal))) && (!(SqlTypeUtil.canAssignFrom(fieldType, literal.getType())))) { throw new AssertionError("to " + fieldType + " from " + literal); } } } }
/** Returns 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; }
/** Returns 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; }
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) { // Do not use callBinding.operands(). We have not resolved to a function // yet, therefore we do not know the ordered parameter names. 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; }
public boolean checkOperandTypes( SqlCallBinding callBinding, boolean throwOnFailure) { // Do not use callBinding.operands(). We have not resolved to a function // yet, therefore we do not know the ordered parameter names. 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; }
final RelDataType dateNotNull = typeFactory.createTypeWithNullability(date, false); assertThat(SqlTypeUtil.canAssignFrom(bigintNullable, bigintNotNull), is(true)); assertThat(SqlTypeUtil.canAssignFrom(bigintNullable, dateNotNull), is(false)); final RelDataType bigintNullableArray = final RelDataType bigintNotNullArray = new ArraySqlType(bigintNotNull, false); assertThat(SqlTypeUtil.canAssignFrom(bigintArrayNullable, bigintNotNullArray), is(true)); final RelDataType dateNotNullArray = new ArraySqlType(dateNotNull, false); assertThat(SqlTypeUtil.canAssignFrom(bigintArrayNullable, dateNotNullArray), is(false));
final RelDataType dateNotNull = typeFactory.createTypeWithNullability(date, false); assertThat(SqlTypeUtil.canAssignFrom(bigintNullable, bigintNotNull), is(true)); assertThat(SqlTypeUtil.canAssignFrom(bigintNullable, dateNotNull), is(false)); final RelDataType bigintNullableArray = final RelDataType bigintNotNullArray = new ArraySqlType(bigintNotNull, false); assertThat(SqlTypeUtil.canAssignFrom(bigintArrayNullable, bigintNotNullArray), is(true)); final RelDataType dateNotNullArray = new ArraySqlType(dateNotNull, false); assertThat(SqlTypeUtil.canAssignFrom(bigintArrayNullable, dateNotNullArray), is(false));
return false; return canAssignFrom(toType.getComponentType(), fromType.getComponentType());
return false; return canAssignFrom(toType.getComponentType(), fromType.getComponentType());
return false; return canAssignFrom(toType.getComponentType(), fromType.getComponentType());