You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Mihai Budiu (Jira)" <ji...@apache.org> on 2025/05/07 23:30:00 UTC
[jira] [Created] (CALCITE-7002) Create an optimization rule to eliminate UNION from the same source with different filters
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)