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

Feng Zhu commented on CALCITE-3433:
-----------------------------------

The bug is caused by wrong codegen for BinaryExpression. Even the expressions 
are box types, it still adopts "==" to compare them.

The code for "union" query is demonstated as below, while for the other correct 
query, the comparison is simplified as "true" before codegen phase.
{code:java}
 public Object current() {
   final Object[] current = (Object[]) inputEnumerator.current();
   final Long inp0_ = (Long) current[0];
   final Long inp1_ = (Long) current[1];
   return inp0_ == null || inp1_ == null ? (Boolean) null : 
Boolean.valueOf(inp0_ == inp1_);
}
{code}
I will take a look and fix this issue

> EQUALS operator between date/timestamp types returns false if the type is 
> nullable
> ----------------------------------------------------------------------------------
>
>                 Key: CALCITE-3433
>                 URL: https://issues.apache.org/jira/browse/CALCITE-3433
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.17.0, 1.18.0, 1.19.0, 1.20.0, 1.21.0
>            Reporter: jiezouSH
>            Priority: Major
>
> sql
> select time0=time1 from (select timestamp'2000-12-30 21:07:32'as 
> time0,timestamp'2000-12-30 21:07:32'as time1 union all select cast(null as 
> timestamp) as time0,cast(null as timestamp) as time1) calcs
> answer is false
> but 
> sql
> select time0=time1 from (select timestamp'2000-12-30 21:07:32'as 
> time0,timestamp'2000-12-30 21:07:32'as time1) calcs
> answer is true
>  



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

Reply via email to