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

Benchao Li updated CALCITE-5247:
--------------------------------
    Description: 
For the following query:
{code:sql}
SELECT 
  * 
FROM 
  (
    SELECT 
      A.C0 AS L, 
      B.C1 AS R1, 
      B.C2 AS R2 
    FROM 
      A 
      LEFT JOIN B
  ) 
WHERE 
  (R1 IS NOT NULL) 
  OR (R2 IS NOT NULL)
{code}
it should be optimized to
{code:sql}
SELECT 
  * 
FROM 
  (
    SELECT 
      A.C0 AS L, 
      B.C1 AS R1, 
      B.C2 AS R2 
    FROM 
      A 
      LEFT JOIN B
  ) 
WHERE 
  (R1 IS NOT NULL) 
  OR (R2 IS NOT NULL)
{code}
 

The FilterJoinRule fails to simplify this specific case, however if we have 
only 1 IS_NOT_NULL in the filter condition, it is able to do so.
I think the problem is in the Strong class.

  was:
In this specific case:

Table A
Table B

FILTER(OR (IS NOT NULL(B.C0), IS NOT NULL(B.C1)))
A LEFT JOIN B
->
A INNER JOIN B


The FilterJoinRule fails to simplify this specific case, however if we have 
only 1 IS_NOT_NULL in the filter condition, it is able to do so.
I think the problem is in the Strong class.


> FilterJoinRule cannot simplify left join to inner join for `WHERE RHS.C1 IS 
> NOT NULL OR RHS.C2 IS NOT NULL`
> -----------------------------------------------------------------------------------------------------------
>
>                 Key: CALCITE-5247
>                 URL: https://issues.apache.org/jira/browse/CALCITE-5247
>             Project: Calcite
>          Issue Type: Improvement
>          Components: core
>    Affects Versions: 1.25.0, 1.31.0
>            Reporter: Ali Mansour
>            Priority: Major
>
> For the following query:
> {code:sql}
> SELECT 
>   * 
> FROM 
>   (
>     SELECT 
>       A.C0 AS L, 
>       B.C1 AS R1, 
>       B.C2 AS R2 
>     FROM 
>       A 
>       LEFT JOIN B
>   ) 
> WHERE 
>   (R1 IS NOT NULL) 
>   OR (R2 IS NOT NULL)
> {code}
> it should be optimized to
> {code:sql}
> SELECT 
>   * 
> FROM 
>   (
>     SELECT 
>       A.C0 AS L, 
>       B.C1 AS R1, 
>       B.C2 AS R2 
>     FROM 
>       A 
>       LEFT JOIN B
>   ) 
> WHERE 
>   (R1 IS NOT NULL) 
>   OR (R2 IS NOT NULL)
> {code}
>  
> The FilterJoinRule fails to simplify this specific case, however if we have 
> only 1 IS_NOT_NULL in the filter condition, it is able to do so.
> I think the problem is in the Strong class.



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

Reply via email to