You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Rong Rong (Jira)" <ji...@apache.org> on 2023/06/03 01:00:11 UTC

[jira] [Comment Edited] (CALCITE-5740) Support for AggToSemiJoinRule

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

Rong Rong edited comment on CALCITE-5740 at 6/3/23 1:00 AM:
------------------------------------------------------------

forgot to post an example

As an example:

{code:sql}
SELECT 
  a.col, COUNT(*) 
FROM 
  a JOIN b ON a.key = b.key
WHERE
  b.val BETWEEN 0 AND 10
{code}

can be converted to 
{code:sql}

SELECT
  col, COUNT(*)
FROM 
  a
WHERE
  a.key IN (SELECT key FROM b WHERE val BETWEEN 0 AND 10)
{code}


was (Author: rongr):
forgot to post an example

As an example:
```
SELECT 
  a.col, COUNT(*) 
FROM 
  a JOIN b ON a.key = b.key
WHERE
  b.val BETWEEN 0 AND 10
```
can be converted to 
```
SELECT
  col, COUNT(*)
FROM 
  a
WHERE
  a.key IN (SELECT key FROM b WHERE val BETWEEN 0 AND 10)
```

> Support for AggToSemiJoinRule
> -----------------------------
>
>                 Key: CALCITE-5740
>                 URL: https://issues.apache.org/jira/browse/CALCITE-5740
>             Project: Calcite
>          Issue Type: New Feature
>            Reporter: Rong Rong
>            Priority: Major
>
> **Description**
> Currently we only have JoinToSemiJoin and ProjectToSemiJoin rule.  which in the rule itself it performance check and see if the project accesses columns from the RHS result
> This can be extended to Aggregate as well, experimental code: https://github.com/walterddr/calcite/pull/1/files
> **Alternative**
> Alternative is to add a project/calc between the join and the aggregate to activate the project-to-semi-join rule. please share if there's any other alternative if I haven't considered. 
> thanks



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