[
https://issues.apache.org/jira/browse/CALCITE-6787?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17913324#comment-17913324
]
Krisztian Kasa commented on CALCITE-6787:
-----------------------------------------
During the initial analysis I found that the code after this condition removes
the {{is not null}} in Calcite 1.25
https://github.com/apache/calcite/blob/61a3d5e9e25d5315f52b79d30d069f61a23dd952/core/src/main/java/org/apache/calcite/rex/RexSimplify.java#L1632-L1634
In Calcite 1.25 we end up with 3 terms
{code}
0 = {RexCall@3089} ">=($0, 0)"
1 = {RexCall@3090} ">=(100, $0)"
2 = {RexCall@3091} "IS NOT NULL($0)"
{code}
hence the condition in the if statement doesn't meet.
In Calcite 1.33 we have only one term with a search operator and we go with
{code}
// Make sure "x OR y OR x" (a single-term conjunction) gets simplified.
return simplify(terms.get(0), FALSE);
{code}
> 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)