[jira] [Commented] (CALCITE-5731) cast to row type should throw exception when contains null/not null constraint

2023-05-30 Thread jackylau (Jira)


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

jackylau commented on CALCITE-5731:
---

1)the issue https://issues.apache.org/jira/browse/CALCITE-5674 fixed the Cast 
expr to target type should respect nullable when it is complex type,

 

2) this  issue tries to fix another

> 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
>Priority: Major
> Fix For: 1.35.0
>
>
> the cast standard grammar it here from iso 2016
> {code:java}
> // code placeholder
>  ::=
> CAST   AS  
>  ::=
> 
> | 
>  ::=
> 
> | 
>  ::=
> 
> | 
> | 
> | 
> | 
>  ::=
> 
> | 
>  ::=
>  ARRAY
> [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)


[jira] [Commented] (CALCITE-5731) cast to row type should throw exception when contains null/not null constraint

2023-05-30 Thread jackylau (Jira)


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

jackylau commented on CALCITE-5731:
---

hi [~libenchao] [~rubenql]  do you have time to review it? 
https://github.com/apache/calcite/pull/3232

> 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
>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   AS  
>  ::=
> 
> | 
>  ::=
> 
> | 
>  ::=
> 
> | 
> | 
> | 
> | 
>  ::=
> 
> | 
>  ::=
>  ARRAY
> [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)


[jira] [Commented] (CALCITE-5731) cast to row type should throw exception when contains null/not null constraint

2023-05-30 Thread Ruben Q L (Jira)


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

Ruben Q L commented on CALCITE-5731:


[~jackylau] thanks bringing up this topic.

I'm not an expert on this part of Calcite, but it seems this is not a bug, but 
a feature. Calcite goes beyond the standard on this specific area; and 
according to git history this was done on purpose in 1.21 via CALCITE-3233 (see 
more info also on its parent ticket CALCITE-3213).
So, IMO we should not undo this, unless there is a clear reason for that.

> 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   AS  
>  ::=
> 
> | 
>  ::=
> 
> | 
>  ::=
> 
> | 
> | 
> | 
> | 
>  ::=
> 
> | 
>  ::=
>  ARRAY
> [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)


[jira] [Commented] (CALCITE-5731) cast to row type should throw exception when contains null/not null constraint

2023-05-30 Thread jackylau (Jira)


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

jackylau commented on CALCITE-5731:
---

but it breaks the sql standard, i guess it may be for flink. hi  [~danny0405] , 
could you explain why you break the sql standard here?

> 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   AS  
>  ::=
> 
> | 
>  ::=
> 
> | 
>  ::=
> 
> | 
> | 
> | 
> | 
>  ::=
> 
> | 
>  ::=
>  ARRAY
> [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)


[jira] [Commented] (CALCITE-5731) cast to row type should throw exception when contains null/not null constraint

2023-06-01 Thread Ruben Q L (Jira)


[ 
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   AS  
>  ::=
> 
> | 
>  ::=
> 
> | 
>  ::=
> 
> | 
> | 
> | 
> | 
>  ::=
> 
> | 
>  ::=
>  ARRAY
> [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)


[jira] [Commented] (CALCITE-5731) cast to row type should throw exception when contains null/not null constraint

2023-06-28 Thread Ruben Q L (Jira)


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

Ruben Q L commented on CALCITE-5731:


[~jackylau] I'm removing the "fixVersion=1.35" from this one. It seems we need 
further clarifications about this issue, and we are approaching the 1.35 RC.

> 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: Jacky Lau
>Assignee: Jacky Lau
>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   AS  
>  ::=
> 
> | 
>  ::=
> 
> | 
>  ::=
> 
> | 
> | 
> | 
> | 
>  ::=
> 
> | 
>  ::=
>  ARRAY
> [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)