You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Ruben Q L (Jira)" <ji...@apache.org> on 2023/06/01 07:54:00 UTC
[jira] [Commented] (CALCITE-5731) cast to row type should throw exception when contains null/not null constraint
[ https://issues.apache.org/jira/browse/CALCITE-5731?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17728251#comment-17728251 ]
Ruben Q L commented on CALCITE-5731:
------------------------------------
What's the problem with the current status (that goes beyond the standard)? Does it break anything?
I was not involved on the original ticket that introduced this change, but I guess [this comment|https://issues.apache.org/jira/browse/CALCITE-3213?focusedCommentId=16895502&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-16895502] summarizes the idea and its benefits.
> cast to row type should throw exception when contains null/not null constraint
> ------------------------------------------------------------------------------
>
> Key: CALCITE-5731
> URL: https://issues.apache.org/jira/browse/CALCITE-5731
> Project: Calcite
> Issue Type: Improvement
> Components: core
> Affects Versions: 1.35.0
> Reporter: jackylau
> Assignee: jackylau
> Priority: Major
> Labels: pull-request-available
> Fix For: 1.35.0
>
>
> the cast standard grammar it here from iso 2016
> {code:java}
> // code placeholder
> <cast specification> ::=
> CAST <left paren> <cast operand> AS <cast target> <right paren>
> <cast operand> ::=
> <value expression>
> | <implicitly typed value specification>
> <cast target> ::=
> <domain name>
> | <data type>
> <data type> ::=
> <predefined type>
> | <row type>
> | <path-resolved user-defined type name>
> | <reference type>
> | <collection type>
> <collection type> ::=
> <array type>
> | <multiset type>
> <array type> ::=
> <data type> ARRAY
> [ <left bracket or trigraph> <maximum cardinality> <right bracket or trigraph> ] {code}
>
> not null/ null are constraint, can not be in cast, only can be in ddl
> {code:java}
> // this simple type and collection type will throw exception in calcite now
> expr("cast(x as integer ^not^ null)")
> .fails("(?s).*Encountered \"not\" at .*");
> expr("cast(x as integer ^not^ null array)")
> .fails("(?s).*Encountered \"not\" at .*");
> expr("cast(x as integer array ^not^ null)")
> .fails("(?s).*Encountered \"not\" at .*");
> // but the followings are not
> expr("cast(x as row(f0 int ^not^ null))")
> .fails("(?s).*Encountered \"not\" at .*");
> expr("cast(x as row(f0 varchar ^null^))")
> .fails("(?s).*Encountered \"null\" at .*");
> expr("cast(x as row(f0 int ^not^ null, f1 varchar ^null^))")
> .fails("(?s).*Encountered \"not\" at .*");{code}
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)