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

Vladislav Pyatkov updated IGNITE-29321:
---------------------------------------
    Description: 
A LEFT JOIN whose ON condition contains `b.opt IS NULL OR EXISTS (...)` fails 
when the correlated subquery references columns from both join inputs.
The failure reproduces with a regular SELECT and when reading the same query 
through a view.

Query example:
{code:sql}
SELECT f.id AS field_id, b.id AS buffer_id
FROM field_def f
LEFT JOIN out_buffer b
    ON b.tag = f.tag
    AND (
        b.opt IS NULL
        OR EXISTS (
            SELECT 1
            FROM field_option fo
            WHERE fo.field_id = f.id
              AND fo.opt = b.opt
        )
    );
{code}

Actual exception:
{noformat}
java.lang.RuntimeException: cannot translate expression EXISTS({
LogicalFilter(condition=[AND(=($3, $cor0.ID), =($4, $cor0.OPT))])
  IgniteLogicalTableScan(table=[[PUBLIC, FIELD_OPTION]])
})
    at org.apache.ignite.internal.processors.query.calcite.exec.exp
        .RexToLixTranslator.visitSubQuery(RexToLixTranslator.java:1297)
{noformat}

  was:
A LEFT JOIN whose ON condition contains `b.opt IS NULL OR EXISTS (...)` fails 
when the correlated subquery references columns from both join inputs.

The failure reproduces with a regular SELECT and when reading the same query 
through a view.


> [Calcite] Correlated EXISTS referencing both join inputs fails in LEFT JOIN 
> ON condition
> ----------------------------------------------------------------------------------------
>
>                 Key: IGNITE-29321
>                 URL: https://issues.apache.org/jira/browse/IGNITE-29321
>             Project: Ignite
>          Issue Type: Bug
>          Components: sql
>            Reporter: Vladislav Pyatkov
>            Priority: Major
>              Labels: calcite, ignite-2, sql
>         Attachments: CorrelatedExistsInJoinIntegrationTest.java
>
>
> A LEFT JOIN whose ON condition contains `b.opt IS NULL OR EXISTS (...)` fails 
> when the correlated subquery references columns from both join inputs.
> The failure reproduces with a regular SELECT and when reading the same query 
> through a view.
> Query example:
> {code:sql}
> SELECT f.id AS field_id, b.id AS buffer_id
> FROM field_def f
> LEFT JOIN out_buffer b
>     ON b.tag = f.tag
>     AND (
>         b.opt IS NULL
>         OR EXISTS (
>             SELECT 1
>             FROM field_option fo
>             WHERE fo.field_id = f.id
>               AND fo.opt = b.opt
>         )
>     );
> {code}
> Actual exception:
> {noformat}
> java.lang.RuntimeException: cannot translate expression EXISTS({
> LogicalFilter(condition=[AND(=($3, $cor0.ID), =($4, $cor0.OPT))])
>   IgniteLogicalTableScan(table=[[PUBLIC, FIELD_OPTION]])
> })
>     at org.apache.ignite.internal.processors.query.calcite.exec.exp
>         .RexToLixTranslator.visitSubQuery(RexToLixTranslator.java:1297)
> {noformat}



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to