You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Julian Hyde (Jira)" <ji...@apache.org> on 2020/11/01 17:49:00 UTC

[jira] [Resolved] (CALCITE-4352) RelBuilder/RexSimplify/Sarg incorrectly transforms complex expressions with IS NULL/IS NOT NULL

     [ https://issues.apache.org/jira/browse/CALCITE-4352?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Julian Hyde resolved CALCITE-4352.
----------------------------------
    Fix Version/s: 1.27.0
       Resolution: Fixed

Fixed in [d03ce475|https://github.com/apache/calcite/commit/d03ce47536ddb2aaec6d445b3ea48464081a7ed0]. Thanks for the test case, [~aigor] (although I refactored your test case to elsewhere in the code before I merged).

> RelBuilder/RexSimplify/Sarg incorrectly transforms complex expressions with IS NULL/IS NOT NULL
> -----------------------------------------------------------------------------------------------
>
>                 Key: CALCITE-4352
>                 URL: https://issues.apache.org/jira/browse/CALCITE-4352
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.27.0
>         Environment: All environments
>            Reporter: Igor Lozynskyi
>            Priority: Major
>              Labels: pull-request-available
>             Fix For: 1.27.0
>
>         Attachments: rex-simplify-issue-tests-3.patch
>
>          Time Spent: 1h 20m
>  Remaining Estimate: 0h
>
> Now, the following query with IS NOT NULL:
> {code:java}
> SELECT *
>  FROM emp
>  WHERE deptno > 20 AND deptno < 30 AND mgr IS NOT NULL{code}
> Is simplified to:
> {code:java}
> SELECT *
>  FROM emp
>  WHERE deptno > 20 AND deptno < 30{code}
> It seems that the simplification of complex `AND` filters incorrectly simplify `IS NOT NULL` to `TRUE`.
>  During simplification, `IS NOT NULL` is transformed to `SEARCH($3, Sarg[(-∞..+∞), null])` instead of `SEARCH($3, Sarg[(-∞..+∞)])`.
> Also, the following query with IS NULL:
> {code:java}
> SELECT *
> FROM emp
> WHERE deptno > 20 AND deptno < 30 AND mgr IS NULL
> {code}
> Is simplified to the following query:
> {code:java}
> SELECT * 
> FROM emp 
> WHERE deptno > 20 AND deptno < 30
> {code}
> However, now it is correct when transformed into a Sarg, but incorrect after `RexUtil.expandSearch()` expansion.
>  
> A simpler query does not show this issue (stays the same):
> {code:java}
> SELECT *
>  FROM emp
>  WHERE mgr IS NOT NULL{code}
> The patch with the corresponding test cases is in attachments.
>  



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