julianhyde commented on a change in pull request #2595:
URL: https://github.com/apache/calcite/pull/2595#discussion_r753511546
##########
File path: core/src/test/java/org/apache/calcite/sql/type/SqlTypeUtilTest.java
##########
@@ -226,4 +227,29 @@ private void compareTypesIgnoringNullability(
compareTypesIgnoringNullability("identical types should return true.",
bigIntType, bigIntType1, true);
}
+
+ @Test public void testCanAlwaysCastToUnknownFromBasic() {
+ RelDataType unknownType = f.typeFactory.createUnknownType();
+ RelDataType nullableUnknownType =
f.typeFactory.createTypeWithNullability(unknownType, true);
+
+ for (SqlTypeName fromTypeName : SqlTypeName.values()) {
+ BasicSqlType fromType;
+ try {
+ // This only works for basic types. Ignore the rest.
+ fromType = (BasicSqlType) f.typeFactory.createSqlType(fromTypeName);
+ } catch (AssertionError e) {
+ continue;
+ }
+ BasicSqlType nullableFromType =
fromType.createWithNullability(!fromType.isNullable);
+
+ assertTrue(SqlTypeUtil.canCastFrom(unknownType, fromType, false));
Review comment:
use `assertThat(... is(true))`
##########
File path:
core/src/test/java/org/apache/calcite/sql/type/SqlTypeFactoryTest.java
##########
@@ -286,4 +288,18 @@ private void checkCreateSqlTypeWithPrecision(
assertThat(tsWithPrecision3 == tsWithPrecision8, is(true));
}
+ /** Test that the {code UNKNOWN} type does not does not change class when
nullified. */
+ @Test void testUnknownCreateWithNullabiliityTypeConsistency() {
Review comment:
typo 'Nullabiliity'
##########
File path: core/src/main/java/org/apache/calcite/sql/type/BasicSqlType.java
##########
@@ -54,7 +54,11 @@
* @param typeName Type name
*/
public BasicSqlType(RelDataTypeSystem typeSystem, SqlTypeName typeName) {
- this(typeSystem, typeName, false, PRECISION_NOT_SPECIFIED,
Review comment:
I am surprised that a basic type can be nullable.
##########
File path: core/src/main/java/org/apache/calcite/rel/rel2sql/SqlImplementor.java
##########
@@ -786,7 +786,7 @@ private SqlNode callToSql(@Nullable RexProgram program,
RexCall call0,
SqlNode fieldOperand = field(ordinal);
return SqlStdOperatorTable.CURSOR.createCall(SqlParserPos.ZERO,
fieldOperand);
}
- if (ignoreCast) {
+ if (ignoreCast || call.getType().getSqlTypeName() ==
SqlTypeName.UNKNOWN) {
Review comment:
need comments to justify this. explain to your audience that UNKNOWN
type means. it's not trivial.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]