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 2021/01/06 00:07:00 UTC

[jira] [Resolved] (CALCITE-4449) Generate nicer SQL for Sarg 'x IS NULL OR x NOT IN (1, 2)'

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

Julian Hyde resolved CALCITE-4449.
----------------------------------
    Resolution: Fixed

Fixed in [8b9618fd|https://github.com/apache/calcite/commit/8b9618fdd42daa14524e8baa69124982f409937a].

> Generate nicer SQL for Sarg 'x IS NULL OR x NOT IN (1, 2)'
> ----------------------------------------------------------
>
>                 Key: CALCITE-4449
>                 URL: https://issues.apache.org/jira/browse/CALCITE-4449
>             Project: Calcite
>          Issue Type: Bug
>            Reporter: Julian Hyde
>            Assignee: Julian Hyde
>            Priority: Major
>             Fix For: 1.27.0
>
>
> When converting the Sarg
> {code:sql}x IS NULL OR x NOT IN (1, 2){code}
> to SQL, Calcite currently generates
> {code:sql}x IS NULL OR x < 1 OR x > 1 AND x < 2 OR x > 2{code}
> This is correct SQL, but is difficult to read unless you know that AND has higher precedence than OR. Either of the following would be better:
> {code:sql}x IS NULL OR x <> 1 AND x <> 2{code}
> {code:sql}x IS NULL OR x NOT IN (1, 2){code}



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