You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Stamatis Zampetakis (Jira)" <ji...@apache.org> on 2025/04/23 16:44:00 UTC

[jira] [Commented] (CALCITE-6787) Simplification process fails to remove the 'is not null' predicate

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

Stamatis Zampetakis commented on CALCITE-6787:
----------------------------------------------

I am not yet sure if the fix should be somewhere in RexSimplify or rather inside the RexUtil.searchShuttle. If it is in RexSimplify then we would have to check if it is possible to remove NULL AS FALSE from {{SEARCH($0, Sarg[[0..100];])}} based on the fact that UnknownAs is FALSE inside a Filter operator. Alternatively, when we expand the search via the shuttle we could possibly take some decision to keep or remove the IS NOT NULL predicate based on the UnknownAs context.
 

> Simplification process fails to remove the 'is not null' predicate
> ------------------------------------------------------------------
>
>                 Key: CALCITE-6787
>                 URL: https://issues.apache.org/jira/browse/CALCITE-6787
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>            Reporter: Krisztian Kasa
>            Priority: Major
>
> Let's have the following expression:
> {code}
> AND(IS NOT NULL($0), <=(0, $0), <=($0, 100))
> {code}
> {{$0}} is a {{nullable integer}} column
> The expression is a filter condition coming from a where clause in a query
> In Calcite 1.25 this expression is simplified to
> {code}
> AND(>=($0, 0), >=(100, $0))
> {code}
> So the {{IS NOT NULL($2)}} predicate is removed.
> In Calcite 1.33
> {code}
> SEARCH($0, Sarg[[0..100]; NULL AS FALSE])
> {code}
> and with {{RexUtil.searchShuttle}} it is transformed to
> {code}
> AND(IS NOT NULL($0), AND(>=($0, 0), <=($0, 100)))
> {code}
> I bumped into this behaviour change when upgrading Calcite in Hive from 1.25 to 1.33 or higher.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)