Mihai Budiu created CALCITE-7002:
------------------------------------

             Summary: Create an optimization rule to eliminate UNION from the 
same source with different filters
                 Key: CALCITE-7002
                 URL: https://issues.apache.org/jira/browse/CALCITE-7002
             Project: Calcite
          Issue Type: Improvement
          Components: core
    Affects Versions: 1.39.0
            Reporter: Mihai Budiu


The following query

{code:sql}
SELECT * FROM T WHERE p0
UNION
SELECT * FROM T WHERE p1
{code}

can be rewritten as 

{code:sql}
SELECT * FROM T WHERE p0 OR p1 
{code}

This works if the the left and right filtered inputs are the same collection.

This should work even when p0 and p1 return 'true' for the same rows, because 
UNION eliminates the duplicates.

A similar rule should work for INTERSECT using AND
 



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

Reply via email to