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

Stamatis Zampetakis commented on CALCITE-3627:
----------------------------------------------

Thanks for the clarification [~donnyzone]!

The result of the row constructor is one thing and the use of IS (NOT) NULL 
predicates on the result of the constructor another. The SQL standard does not 
explicitly say what should be returned when ROW constructor has only null 
values. On the other hand it clearly states what should happen for the IS (NOT) 
NULL predicates when applied to row types. Thus the result of the following 
queries should be the one shown below.
{code:sql}
Q4: SELECT ROW(cast(null as int), cast(null as int)) IS NULL; -- should return 
true 
Q5: SELECT ROW(cast(null as int), cast(null as int)) IS NOT NULL; -- should 
return false
{code}
For Q3, since the standard is not explicit let's check what the others DBs do 
and act in a similar fashion. I assume that they do what you already did in the 
PR.

> Incorrect null semantic for ROW function
> ----------------------------------------
>
>                 Key: CALCITE-3627
>                 URL: https://issues.apache.org/jira/browse/CALCITE-3627
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>            Reporter: Feng Zhu
>            Assignee: Feng Zhu
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 50m
>  Remaining Estimate: 0h
>
> In CALCITE-2464, an in-depth discussion on nullability of structured type has 
> been conducted.
> According to SQL standards, a record's value (with structure type) is 
> considered null if and only if all of its fields are null.
> Based on that, the *ROW* function's return type can be nullable.
> Moreover, current implementor for ROW function's _*NullPolicy*_ 
> (_NullPolicy.ANY_) contradicts its runtime behavior.
> {code:java}
> Query: 
> select ROW(1, cast(null as int))
> Result:
> {1, null}{code}
> However, according to the NullPolicy, the result should be null.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to