[
https://issues.apache.org/jira/browse/CALCITE-7011?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17951170#comment-17951170
]
Alessandro Solimando commented on CALCITE-7011:
-----------------------------------------------
>From the look of it, I'd have bet that this case can be optimized by
>_RexSimplify_ via _ReduceExpressionsRule_, it would be useful to understand
>why this doesn't happen before adding more code to support it. [~xuzifu666],
>can you take a look and share your findings here?
> Filter conditions should be distinct avoid duplicate condition
> --------------------------------------------------------------
>
> Key: CALCITE-7011
> URL: https://issues.apache.org/jira/browse/CALCITE-7011
> Project: Calcite
> Issue Type: New Feature
> Components: core
> Affects Versions: 1.39.0
> Reporter: Yu Xu
> Assignee: Yu Xu
> Priority: Major
> Labels: pull-request-available
> Fix For: 1.40.0
>
>
> sql:
> {code:java}
> select deptno from emp where deptno=1 or deptno in (1,2) {code}
> currently would convert to a plan:
> {code:java}
> LogicalProject(DEPTNO=[$7])
> LogicalFilter(condition=[OR(=($7, 1), =($7, 1), =($7, 2))])
> LogicalTableScan(table=[[CATALOG, SALES, EMP]]) {code}
> we can find that ($7, 1) is duplicate(in this case in would transform to
> multiple OR), we should distinct the conditions as:
> {code:java}
> LogicalProject(DEPTNO=[$7])
> LogicalFilter(condition=[SEARCH($7, Sarg[1, 2])])
> LogicalTableScan(table=[[CATALOG, SALES, EMP]]) {code}
> maybe we can add a new rule to resolve the issue.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)