ihuzenko commented on a change in pull request #1519: [CALCITE-3424] 
AssertionError thrown for user-defined table function with array argument
URL: https://github.com/apache/calcite/pull/1519#discussion_r336456128
 
 

 ##########
 File path: core/src/main/java/org/apache/calcite/jdbc/JavaTypeFactoryImpl.java
 ##########
 @@ -251,13 +253,25 @@ public static RelDataType toSql(final RelDataTypeFactory 
typeFactory,
               type.getFieldNames()),
           type.isNullable());
     } else if (type instanceof JavaType) {
-      return typeFactory.createTypeWithNullability(
-          typeFactory.createSqlType(type.getSqlTypeName()),
-          type.isNullable());
+      Class javaClass = ((JavaType) type).getJavaClass();
+      final RelDataType nonNullType;
+      if (javaClass.isArray()) {
 
 Review comment:
   Issue described in Jira ticket relates to ARRAY assertion inside 
```SqlTypeFactoryImpl```'s assertBasic method: 
   ```java
     private void assertBasic(SqlTypeName typeName) {
       assert typeName != null;
       assert typeName != SqlTypeName.MULTISET
           : "use createMultisetType() instead";
       assert typeName != SqlTypeName.ARRAY
           : "use createArrayType() instead";
       assert typeName != SqlTypeName.ROW
           : "use createStructType() instead";
       assert !SqlTypeName.INTERVAL_TYPES.contains(typeName)
           : "use createSqlIntervalType() instead";
     }
   ```
   For map type assertion isn't fired here and I think it's rare case that 
someone will accept map arguments (or others from the method body) into custom 
table function. 

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to