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

Julian Hyde commented on CALCITE-4756:
--------------------------------------

I'm not sure whether {code}select 1 in (values(null),(null)){code} should be 
valid SQL. Regardless, it should not throw {{AssertionError}}. So there is no 
question that this is a bug. Please update the subject to match the updated 
description.

Generally, Calcite does not allow naked NULL values. If you use NULL, it has to 
be in a context where Calcite can deduce the type. Enclosing in a CAST is a 
good way. So am inclined to say that this query is invalid, and correct 
behavior would be to throw a validation exception before SqlToRel is even 
reached.

> When subquery include NULL value, Calcite should return the right result
> ------------------------------------------------------------------------
>
>                 Key: CALCITE-4756
>                 URL: https://issues.apache.org/jira/browse/CALCITE-4756
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.27.0
>            Reporter: duan xiong
>            Assignee: duan xiong
>            Priority: Major
>
> When I try to design some unit tests for CALCITE-4742. I found Calcite can't 
> handle NULL very well in some subquery.
> For example: 
> {code:java}
> select 1 in (values(null),(null))
> ERROR:
>     java.lang.AssertionError: Conversion to relational algebra failed to 
> preserve datatypes:
>     validated type:
>     RecordType(BOOLEAN NOT NULL EXPR$0) NOT NULL
>     converted type:
>     RecordType(BOOLEAN EXPR$0) NOT NULL
>     rel:
>     LogicalProject(EXPR$0=[IN(1, {
>     LogicalValues(tuples=[[{ null }]])
>     })])
>       LogicalValues(tuples=[[{ 0 }]])
> select 1 > some(values(null),(null))
> ERROR:
>     Suppressed: java.lang.RuntimeException: while resolving method 
> 'voidValue' in class class java.lang.Void{code}
> This SQL should return NULL. But throw the runtime exception.



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

Reply via email to