[ 
https://issues.apache.org/jira/browse/CALCITE-6275?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17888270#comment-17888270
 ] 

Dmitry Sysolyatin edited comment on CALCITE-6275 at 10/10/24 3:47 PM:
----------------------------------------------------------------------

Unparsing logic occurs at the SqlNode level. Even if it were possible to 
unparse RelDataType, there are other issues:
# What if someone wants to convert RelNode to SqlNode using RelToSqlConverter? 
How can we handle the conversion of ArraySqlType to SqlCollectionTypeNameSpec, 
given that ArraySqlType.elementType has an nullable property, but 
SqlCollectionTypeNameSpec,elementType does not?
# what happens when someone manually constructs a SqlNode? In such cases, it's 
impossible to define the nullability of elements within the array.


was (Author: dmsysolyatin):
Unparsing logic occurs at the SqlNode level. Even if it were possible to 
unparse RelDataType, there are other issues:
# What if someone wants to convert RelNode to SqlNode using RelToSqlConverter? 
How can we handle the conversion of ArraySqlType to SqlCollectionTypeNameSpec, 
given that ArraySqlType has an isNullable property, but 
SqlCollectionTypeNameSpec does not?
# what happens when someone manually constructs a SqlNode? In such cases, it's 
impossible to define the nullability of elements within the array.

> 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
>             Fix For: 1.38.0
>
>
> 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)

Reply via email to