Uploaded image for project: 'Calcite'
  1. Calcite
  2. CALCITE-2978

sorting not applied in subqueries

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Invalid
    • 1.19.0
    • 1.21.0
    • None
    • None

    Description

      CREATE TABLE test (id INT, val INT);
      INSERT INTO test VALUES (1,1);
      INSERT INTO test VALUES (2,2);
      INSERT INTO test VALUES (3,3);
      INSERT INTO test VALUES (4,4);
      
      
      SELECT id FROM (SELECT id, val FROM test ORDER BY val DESC);
       

      Looks like CALCITE-2798 removes the sorting in sub-queries too aggressively.

      Update:
      I might be wrong here and jumped the gun too early.
      Looks like SQL does not dictate that the outer query has to retain any order of the inner query.
      The sort is applied if a LIMIT is specified in the inner query, to reduce the inner result correctly.

      Happy to close as invalid.

      Attachments

        Issue Links

          Activity

            People

              danny0405 Danny Chen
              psockali Pressenna
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: