You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "xiong duan (Jira)" <ji...@apache.org> on 2022/03/02 11:19:00 UTC
[jira] [Commented] (CALCITE-1794) CAST operator prevent SARG to optimize "x <>2 and x = 1"
[ https://issues.apache.org/jira/browse/CALCITE-1794?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17500060#comment-17500060 ]
xiong duan commented on CALCITE-1794:
-------------------------------------
[~julianhyde]. I have updated the issue description and summary. If you have free time, please review it .
> CAST operator prevent SARG to optimize "x <>2 and x = 1"
> --------------------------------------------------------
>
> Key: CALCITE-1794
> URL: https://issues.apache.org/jira/browse/CALCITE-1794
> Project: Calcite
> Issue Type: Improvement
> Components: core
> Affects Versions: 1.29.0
> Reporter: Remus Rusanu
> Assignee: xiong duan
> Priority: Major
> Labels: pull-request-available
> Time Spent: 20m
> Remaining Estimate: 0h
>
> For example:
> {code:java}
> x = 1 and x <> 2{code}
> In optimizer procedure, We pull up "x = 1" first, then when we encounter "x <> 2", can be simplified to "x = 1". So the result will be "x = 1"
> {code:java}
> x <> 2 and x = 1{code}
> When we pull up "x <> 2" first, it can't optimize the "x = 1". So we need SARG to optimize it again.
> Because EQUALS and NOT-EQUALS operator will make the left RexNode become *[CAST($t0): INTEGER NOT NULL]* when the left node and right node have a least restrictive type. So we need to handle the CAST operator.
--
This message was sent by Atlassian Jira
(v8.20.1#820001)