Java Code Examples for org.apache.calcite.sql.type.SqlTypeUtil#canAssignFrom()

The following examples show how to use org.apache.calcite.sql.type.SqlTypeUtil#canAssignFrom() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ValuesRel.java    From dremio-oss with Apache License 2.0 6 votes vote down vote up
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);
        }
      }
    }

}
 
Example 2
Source File: Schemas.java    From Bats with Apache License 2.0 4 votes vote down vote up
private static boolean canConvert(RelDataType fromType, RelDataType toType) {
  return SqlTypeUtil.canAssignFrom(toType, fromType);
}
 
Example 3
Source File: Schemas.java    From calcite with Apache License 2.0 4 votes vote down vote up
private static boolean canConvert(RelDataType fromType, RelDataType toType) {
  return SqlTypeUtil.canAssignFrom(toType, fromType);
}