You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@calcite.apache.org by "yanjing.wang (Jira)" <ji...@apache.org> on 2022/01/21 06:38:00 UTC
[jira] [Created] (CALCITE-4990) Add SetOpFilterMergeRule for Converting UNION with same inputs but different filters to single input with OR Filter
yanjing.wang created CALCITE-4990:
-------------------------------------
Summary: 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
Environment: 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}
Reporter: yanjing.wang
Assignee: yanjing.wang
Fix For: 1.30.0
Attachments: UnionAllToOr-1.png
--
This message was sent by Atlassian Jira
(v8.20.1#820001)