zabetak commented on a change in pull request #898: [CALCITE-2464] Allow to set 
nullability for columns of structured types (Ruben Quesada Lopez)
URL: https://github.com/apache/calcite/pull/898#discussion_r258886000
 
 

 ##########
 File path: core/src/main/java/org/apache/calcite/jdbc/JavaTypeFactoryImpl.java
 ##########
 @@ -244,10 +244,11 @@ public RelDataType toSql(RelDataType type) {
   public static RelDataType toSql(final RelDataTypeFactory typeFactory,
       RelDataType type) {
     if (type instanceof RelRecordType) {
-      return typeFactory.createStructType(
-          Lists.transform(type.getFieldList(),
-              field -> toSql(typeFactory, field.getType())),
-          type.getFieldNames());
+      return typeFactory.createTypeWithNullability(
 
 Review comment:
   Since for the moment there is no other createType method who takes 
nullability as a parameter I would say not to add a new one in the public API. 
On the other hand maybe we can avoid the problem of multiple traversals by 
adding a new 
   `private static RelDataType toSql(final RelDataTypeFactory typeFactory, 
RelDataType type, boolean changeNullability) `
   with which we can control when we have to change nullability. In any case 
only the top-level nullability is important for structs since the nullability 
of nested fields can be erased by the current code in createTypeWithNullability.
   
   What do you think?
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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