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

Sql. Set operation. Incorrect query transformation for a query with limit / offset and sort

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Critical
    • Resolution: Fixed
    • 3.0.0-beta2
    • 3.0.0-beta2
    • sql

    Description

      Query

      SELECT a FROM
        (SELECT a FROM
          (SELECT a FROM test ORDER BY a LIMIT 3 OFFSET 2) i(a)
          ORDER BY a OFFSET 1
        ) t(a)
      

      Should be transformed into

       Limit(offset=[1]), id = 201
         Limit(offset=[2], fetch=[3]), id = 200
           Exchange(distribution=[single]), id = 199
             Sort(sort0=[$0], dir0=[ASC], offset=[2], fetch=[3]), id = 198
               TableScan(table=[[PUBLIC, TEST]], requiredColumns=[{0}]), id = 168
      

      But it gets rewritten as

       Limit(offset=[1]), id = 201
         Limit(offset=[2], fetch=[3]), id = 200
           Exchange(distribution=[single]), id = 199
             Sort(sort0=[$0], dir0=[ASC], offset=[1], fetch=[1]), id = 198
               TableScan(table=[[PUBLIC, TEST]], requiredColumns=[{0}]), id = 168
      

      Attachments

        Issue Links

          Activity

            People

              mzhuravkov Maksim Zhuravkov
              mzhuravkov Maksim Zhuravkov
              Votes:
              0 Vote for this issue
              Watchers:
              3 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 - 20m
                  20m