You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by " EveyWu (Jira)" <ji...@apache.org> on 2024/06/27 07:02:00 UTC

[jira] [Comment Edited] (CALCITE-6447) Extract common expressions for disjunctions in Join

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

 EveyWu edited comment on CALCITE-6447 at 6/27/24 7:01 AM:
-----------------------------------------------------------

[~frostruan]  for test `testWhereAnyCorrelatedInSelect`.  I think this is expected too, this PR optimizes conditions.

```

(EMP.EMPNO > DEPT.m AND NOT (DEPT.trueLiteral IS NULL OR DEPT.c = 0))
OR
(EMP.EMPNO > DEPT.m AND NOT (DEPT.trueLiteral IS NULL OR DEPT.c = 0) AND NOT (EMP.EMPNO > DEPT.m) AND NOT (DEPT.c > DEPT.d))

```

after optimize

```

EMP.EMPNO > DEPT.m AND NOT (DEPT.trueLiteral IS NULL OR DEPT.c = 0)

```

 


was (Author: eveywu):
[~frostruan]  for test `testWhereAnyCorrelatedInSelect`.  I think this is expected too, this PR optimizes conditions.

```

(EMP.EMPNO > DEPT.m AND NOT (DEPT.trueLiteral IS NULL OR DEPT.c = 0))
OR
(EMP.EMPNO > DEPT.m AND NOT (DEPT.trueLiteral IS NULL OR DEPT.c = 0) AND NOT (EMP.EMPNO > DEPT.m) AND NOT (DEPT.c > DEPT.d))

```

after optimize

```

EMP.EMPNO > DEPT.m AND NOT (DEPT.trueLiteral IS NULL OR DEPT.c = 0)

```

 

> Extract common expressions for disjunctions in Join
> ---------------------------------------------------
>
>                 Key: CALCITE-6447
>                 URL: https://issues.apache.org/jira/browse/CALCITE-6447
>             Project: Calcite
>          Issue Type: New Feature
>          Components: core
>    Affects Versions: 1.37.0
>            Reporter: ruanhui
>            Priority: Minor
>              Labels: pull-request-available
>             Fix For: 1.37.0
>
>         Attachments: image-2024-06-25-16-26-15-058.png
>
>
> For SQL:
> {code:java}
> select *
> from tbl_a
>   join tbl_b on tbl_a.id = tbl_b.id
> where (tbl_a.x > 100 and tbl_b.y < 10)
>    or (tbl_a.x > 100 and tbl_b.z > 20){code}
> we can rewrite it to
> {code:java}
> select *
> from tbl_a
>   join tbl_b on tbl_a.id = tbl_b.id
> where tbl_a.x > 100
>   and (tbl_b.y < 10 or tbl_b.z > 20){code}
> And in this way *tbl_a.x > 100* can be pushed down and it is likely that this will help reduce the amount of data involved in the join.



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