You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Dmitry Sysolyatin (Jira)" <ji...@apache.org> on 2024/10/09 09:33:00 UTC
[jira] [Commented] (CALCITE-6275) Parser for data types ignores element nullability in collections
[ https://issues.apache.org/jira/browse/CALCITE-6275?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17887866#comment-17887866 ]
Dmitry Sysolyatin commented on CALCITE-6275:
--------------------------------------------
Hi [~mbudiu]
I created a similar bug related to the nullability of elements inside SqlCollectionTypeNameSpec [1], but without the parsing part, as I was more interested in the unparsing part. The issue arose because the ClickHouse SQL dialect supports specifying the nullability of a collection. Here's an example:
{code:java}
CREATE TABLE t_arr
(
`arr` Array(Nullable(UInt8))
)
ENGINE = MergeTree
ORDER BY tuple()
{code}
So, I believe that this bug is valid.
[1] https://issues.apache.org/jira/browse/CALCITE-6101
> 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)