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/04/25 00:25:00 UTC
[jira] [Resolved] (CALCITE-6973) Add rule to convert Minus to Filter
[ https://issues.apache.org/jira/browse/CALCITE-6973?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Mihai Budiu resolved CALCITE-6973.
----------------------------------
Fix Version/s: 1.40.0
Resolution: Fixed
Fixed in https://github.com/apache/calcite/commit/aa11fd6e5402de239ebb6ed8f2b82b8b449eedbd
Thank you for the contribution [~jensen]
Thank you for the reviews [~asolimando][~nobigo]
> Add rule to convert Minus to Filter
> -----------------------------------
>
> Key: CALCITE-6973
> URL: https://issues.apache.org/jira/browse/CALCITE-6973
> Project: Calcite
> Issue Type: New Feature
> Reporter: Zhen Chen
> Priority: Major
> Labels: pull-request-available
> Fix For: 1.40.0
>
>
> Replaceing Minus with Filter when both inputs are from the same source with only filter conditions differing.
> SQL like
> {code:java}
> SELECT mgr, comm FROM emp WHERE mgr = 12
> EXCEPT
> SELECT mgr, comm FROM emp WHERE comm = 5
> ==>
> SELECT DISTINCT mgr, comm FROM emp
> WHERE mgr = 12 AND NOT(comm = 5) {code}
> Plan like
> {code:java}
> LogicalMinus(all=[false])
> LogicalFilter(condition=[=($0, 12)])
> LogicalProject(MGR=[$3], COMM=[$6])
> LogicalTableScan(table=[[CATALOG, SALES, EMP]])
> LogicalFilter(condition=[=($1, 5)])
> LogicalProject(MGR=[$3], COMM=[$6])
> LogicalTableScan(table=[[CATALOG, SALES, EMP]])
> ==>
> LogicalAggregate(group=[{0, 1}])
> LogicalFilter(condition=[AND(=($0, 12), <>($1, 5))])
> LogicalProject(MGR=[$3], COMM=[$6])
> LogicalTableScan(table=[[CATALOG, SALES, EMP]])
> {code}
> Some plans may contain complex alternating Filter and Project, which are not handled by this rule. Prerequisite rules are required to normalize such cases first. Currently only supports ALL is false and 2-way Minus.
>
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)