weihua zhang created CALCITE-7379:
-------------------------------------

             Summary: LHS correlated variables are shadowed by nullable RHS 
outputs in LEFT JOIN
                 Key: CALCITE-7379
                 URL: https://issues.apache.org/jira/browse/CALCITE-7379
             Project: Calcite
          Issue Type: Bug
          Components: core
            Reporter: weihua zhang


{code:sql}
WITH
  t1(a, b, c) AS (
    VALUES
      (2, 2, 2),
      (3, 3, 3),
      (4, 4, 4)
  ),
  t2(a, b, c) AS (
    VALUES
      (1, 1, 1),
      (3, 3, 3),
      (4, 4, 4)
  ),
  t3(a, b, c) AS (
    VALUES
      (1, 1, 1),
      (2, 2, 2),
      (4, 4, 4)
  )
SELECT * FROM t1 WHERE EXISTS (
SELECT * FROM t2
LEFT JOIN
(SELECT * FROM t3 WHERE t3.a = t1.a) foo
ON t2.a = foo.a
);
{code}

return wrong result:

{noformat}
4, 4, 4
{noformat}

right result is:
{noformat}
2, 2, 2
3, 3, 3
4, 4, 4
{noformat}




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

Reply via email to