[ 
https://issues.apache.org/jira/browse/CALCITE-4990?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

yanjing.wang updated CALCITE-4990:
----------------------------------
    Description: 
The attached diagram illustrates how the new rule works.

 

!UnionAllToOr-1.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}
    Environment:     (was: 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}
 

 

 

 )

> 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-1.png
>
>
> The attached diagram illustrates how the new rule works.
>  
> !UnionAllToOr-1.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