[ https://issues.apache.org/jira/browse/CALCITE-4085?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17147507#comment-17147507 ]
Danny Chen commented on CALCITE-4085: ------------------------------------- Thanks [~dwysakowicz] i'm back from the holidays ~ The fix in AliasNamespace may seems hacky but at least it keeps same logic with the JavaType constructor for the fields nullability. To treat a JavaType as row type is a special case, either we fix the nullability in JavaType when constructing it, either in the AliasNamespace. The problem by fixing the JavaType is that we lose the primitive type info if the record type is nullable. The problem by fixing the AliasNamespace is that we would have a nullable JavaType with non-nullable fields, if we did a projection from it, i.e. "select nullableJavaType.a from ..." the type would be non-nullable which is wrong. The problem with JavaType is very same with the your POJO example, the common case is a nullable SQL type with a primitive Java type underlying. I haven't figure out a good way at the moment though, i'm wondering if we can give a common solution instead of pushing some useless codes to Calcite to let downstream projects to hack in. > Improve nullability support for fields of structured type > --------------------------------------------------------- > > Key: CALCITE-4085 > URL: https://issues.apache.org/jira/browse/CALCITE-4085 > Project: Calcite > Issue Type: Improvement > Components: core > Reporter: Dawid Wysakowicz > Assignee: Dawid Wysakowicz > Priority: Major > Time Spent: 20m > Remaining Estimate: 0h > > As discussed in > https://lists.apache.org/thread.html/r602ac95fff23dd1ef974fb396df7be061ab861384ec42f5c57ce0bc2%40%3Cdev.calcite.apache.org%3E > I would like to change the way a type of a field of a record is derived at > couple of locations. This helps frameworks such as Apache Flink to build > support for nullable records with not null fields. > I suggest to change: > * SqlDotOperator#deriveType > * SqlItemOperator#inferReturnType > * AliasNamespace#validateImpl > * RexBuilder#makeFieldAccessInternal > * SqlValidatorImpl.DeriveTypeVisitor#visit(SqlIdentifier) -- This message was sent by Atlassian Jira (v8.3.4#803005)