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

Calcite engine. Wrong result for single-value aggregation from empty source

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • None
    • None
    • None

    Description

      For example:

      SELECT (SELECT 1 FROM (SELECT 1) WHERE 1 = 0)
      

      Returns 0, but expected NULL.

      With correlated queries result even more strange:

      CREATE TABLE test (a INTEGER)
      INSERT INTO test VALUES (1), (2), (null)
      SELECT (SELECT 1 FROM test t WHERE a = test.a) FROM test
      

      Returns 1, 1, 1 (expected 1, 1, NULL)

      Related test test_correlated_subquery.test_ignore

      From SQL standard:

      Let SS be a <scalar subquery>.
      Case:
      a) If the cardinality of SS is greater than 1 (one), then an exception condition is raised: cardinality violation.
      b) If the cardinality of SS is 0 (zero), then the value of the <scalar subquery> is the null value.
      c) Otherwise, let C be the column of <query expression> simply contained in SS. The value of SS is the value of C in the unique row of the result of the <scalar subquery>.

      Attachments

        Issue Links

          Activity

            People

              vladsz83 Vladimir Steshin
              alex_pl Aleksey Plekhanov
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 40m
                  40m