You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by GitBox <gi...@apache.org> on 2021/11/20 09:32:29 UTC

[GitHub] [calcite] vlsi commented on a change in pull request #2595: [CALCITE-4872] Make new UNKNOWN SqlTypeName, distinct from NULL (Will Noble)

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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org