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

yanjing.wang commented on CALCITE-4990:
---------------------------------------

I have a draft version on 
[branch|https://github.com/hannerwang/calcite/tree/union_all_fusion_to_single] 
,Welcome review, and any suggestions will be appreciated.

> Add SetOpFilterMergeRule for Converting UNION with same inputs but different 
> filters to single input with OR Filter
> -------------------------------------------------------------------------------------------------------------------
>
>                 Key: CALCITE-4990
>                 URL: https://issues.apache.org/jira/browse/CALCITE-4990
>             Project: Calcite
>          Issue Type: Wish
>          Components: core
>    Affects Versions: 1.29.0
>            Reporter: yanjing.wang
>            Assignee: yanjing.wang
>            Priority: Major
>             Fix For: 1.30.0
>
>         Attachments: UnionAllToOr.png
>
>
> The attached diagram illustrates how the new rule works.
> !UnionAllToOr.png!
> The rule will be useful when Input Sub Tree is a computing-intensive or large 
> IO operation, 
> and it works for N-way Union, not just 2-way Union. In addition, The Project 
> operator will be optional present.
>  
> It has some prerequisites when applying the rule to rel.
> 1. Project and Input Sub Tree must be identical.
> 2. For UNION: 
> New Filter = left Filter OR right Filter.
> For UNION ALL: 
> left Filter, right Filter must have no overlap.
>  
> Example:
> {code:java}
> SELECT a, b FROM t WHERE c = 1 
> UNION ALL 
> SELECT a, b FROM t WHERE c = 2 
> UNION ALL 
> SELECT a, b FROM t WHERE c = 3   {code}
> After applying the rule, we get
> {code:java}
> SELECT a, b FROM t WHERE c in (1, 2, 3)   {code}



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to