You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Chunwei Lei (Jira)" <ji...@apache.org> on 2022/06/15 01:43:00 UTC

[jira] [Resolved] (CALCITE-5169) 'xx < 1 OR xx > 1' cannot be simplified to 'xx <> 1'

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

Chunwei Lei resolved CALCITE-5169.
----------------------------------
    Resolution: Fixed

Fixed in [https://github.com/apache/calcite/commit/e64a21ee27600537e0498cd1f72475ad1a1a0d2b|https://github.com/apache/calcite/commit/e64a21ee27600537e0498cd1f72475ad1a1a0d2b.]. Thank you for your PR, [~libenchao]!

> 'xx < 1 OR xx > 1' cannot be simplified to 'xx <> 1'
> ----------------------------------------------------
>
>                 Key: CALCITE-5169
>                 URL: https://issues.apache.org/jira/browse/CALCITE-5169
>             Project: Calcite
>          Issue Type: Improvement
>          Components: core
>    Affects Versions: 1.30.0
>            Reporter: Benchao Li
>            Assignee: Benchao Li
>            Priority: Major
>              Labels: pull-request-available
>             Fix For: 1.31.0
>
>          Time Spent: 1h 10m
>  Remaining Estimate: 0h
>
> As described in the title, {{xx < 1 OR xx > 1}} should be simplified to {{xx <> 1}}.
> See discussion in ML: https://lists.apache.org/thread/hsdgx0jb3214v6k9p7slbkk3xsbl0b7f
> The original problem is that {{ename <> '' and ename <> '3'}} could be simplified to {{Sarg}} while {{(ename < '' or ename > '') and (ename < '3' or ename > '3')}} cannot.
> Since {{<}} and {{<>}} have different {{SqlOperandTypeChecker.Consistency}}, the type inference result is different for these two cases. We suspect that the type inference result leads to the difference of simplification. 
> However, the real reason is that {{xx < 1 OR xx > 1}} cannot be simplified to {{xx <> 1}} in simplification, which prevents {{(ename < '' or ename > '') and (ename < '3' or ename > '3')}} being simplified to {{ename <> '' and ename <> '3'}}.



--
This message was sent by Atlassian Jira
(v8.20.7#820007)