[
https://issues.apache.org/jira/browse/CALCITE-6275?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17888398#comment-17888398
]
Julian Hyde commented on CALCITE-6275:
--------------------------------------
I agree with re-opening. We should be able to parse and unparse types with NOT
NULL annotations, for those that want them. I don't want to commit to
supporting it in Calcite's default mode (and I'm not convinced that it is
desirable) but the parser/unparser should have the capability available.
I agree with [~dmsysolyatin]'s comment that type information is not available
in the AST (SqlNode) but maybe we can generate those NOT NULL annotations into
the AST if a flag enables it.
> Parser for data types ignores element nullability in collections
> ----------------------------------------------------------------
>
> Key: CALCITE-6275
> URL: https://issues.apache.org/jira/browse/CALCITE-6275
> Project: Calcite
> Issue Type: Bug
> Components: core, server
> Affects Versions: 1.36.0
> Reporter: Mihai Budiu
> Priority: Major
> Labels: pull-request-available
>
> The parser (Parser.jj) has this production rule for DataType:
> {code}
> // Type name with optional scale and precision.
> SqlDataTypeSpec DataType() :
> {
> SqlTypeNameSpec typeName;
> final Span s;
> }
> {
> typeName = TypeName() {
> s = Span.of(typeName.getParserPos());
> }
> (
> typeName = CollectionsTypeName(typeName)
> )*
> {
> return new SqlDataTypeSpec(typeName,
> s.add(typeName.getParserPos()).pos());
> }
> }
> {code}
> Note that there is no way to specify the nullability for the elements of a
> collection, they are always assumed to be non-null. This is most pertinent
> for the server component, where in DDL one cannot specify a table column of
> type INTEGER ARRAY; one always gets an INTEGER NOT NULL ARRAY instead.
> But note that SqlCollectionTypeNameSpec cannot even represent the nullability
> of the elements' type, it takes a SqlTypeNameSpec instead of a
> SqlDataTypeSpec.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)