rubenada 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_r258820630
##########
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:
Another possibility will be avoiding the `createTypeWithNullability` call
and create the struct type directly with the appropriate nullability via the
typeFactory:
```
typeFactory.createStructType(
Lists.transform(type.getFieldList(), field -> toSql(typeFactory,
field.getType())),
type.getFieldNames(),
type.isNullable());
```
This is totally possible, but it would require to add a new method to
RelDataTypeFactory interface:
```
private RelDataType createStructType(StructKind kind,
final List<RelDataType> typeList,
final List<String> fieldNameList,
final boolean nullable)
```
This method is already defined (though for the moment as `private`) in
RelDataTypeFactoryImpl.
----------------------------------------------------------------
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