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/12/28 21:28:00 UTC
[jira] [Updated] (CALCITE-4449) Calcite generates incorrect 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 updated CALCITE-4449:
---------------------------------
Summary: Calcite generates incorrect SQL for Sarg 'x IS NULL OR x NOT IN (1, 2)' (was: When converting Sarg 'x IS NULL OR x NOT IN (1, 2)', generate better SQL)
> Calcite generates incorrect 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
> Priority: Major
>
> When converting the Sarg
> {code:java}
> x IS NULL OR x NOT IN (1, 2){code}
> to SQL, Calcite currently generates
> {code:java}
> x IS NULL OR x < 1 OR x > 1 AND x < 2 OR x > 2{code}
> This is incorrect (because {{AND}} has higher precedence than {{OR}}) and also ugly. Adding parentheses makes it correct:
> {code:java}
> x IS NULL OR (x < 1 OR x > 1) AND (x < 2 OR x > 2){code}
> But it's still ugly. Using {{NOT IN}} or {{<>}} would be ideal:
> {code:java}
> x IS NULL OR x <> 1 AND x <> 2{code}
>
--
This message was sent by Atlassian Jira
(v8.3.4#803005)