vlsi commented on a change in pull request #2595:
URL: https://github.com/apache/calcite/pull/2595#discussion_r753655898



##########
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:
       I would rather suggest refactoring the test into `@ParameterizedTest` or 
creating a small `assertCanCastFrom(...)`, so the code becomes less noisy, and 
`assertCanCastFrom` could have clarification messages that explain which case 
failed (what was the input)




-- 
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]


Reply via email to