Uploaded image for project: 'Ignite'
  1. Ignite
  2. IGNITE-15592

Calcite. Unexpected result with implicit join with correlated expression in filter.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Duplicate
    • None
    • None
    • sql

    Description

      statement ok
      CREATE TABLE integers(i INTEGER)
      
      statement ok
      INSERT INTO integers VALUES (1), (2), (3), (NULL)
      
      # implicit join with correlated expression in filter
      query II
      SELECT i, (SELECT s1.i FROM integers s1, integers s2 WHERE s1.i=s2.i AND s1.i=4-i1.i) AS j FROM integers i1 ORDER BY i NULLS FIRST;
      ----
      NULL	NULL
      1	3
      2	2
      3	1
      
      # join with a correlated expression in the join condition
      query II
      SELECT i, (SELECT s1.i FROM integers s1 INNER JOIN integers s2 ON s1.i=s2.i AND s1.i=4-i1.i) AS j FROM integers i1 ORDER BY i NULLS FIRST;
      ----
      NULL	NULL
      1	3
      2	2
      3	1
      
      query II
      SELECT i, (SELECT i FROM integers WHERE i IS NOT NULL EXCEPT SELECT i FROM integers WHERE i<>i1.i) AS j FROM integers i1 WHERE i IS NOT NULL ORDER BY i;
      ----
      1	1
      2	2
      3	3
      
      /subquery/scalar/test_complex_correlated_subquery.test[_ignore]
      

      checked with mysql, all ok there.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              zstan Evgeny Stanilovsky
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: