Uploaded image for project: 'Couchbase Server'
  1. Couchbase Server
  2. MB-51410

UnnestScan with explicit Unnest returns wrong results

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Critical
    • 7.1.0
    • 7.1.0
    • query
    • Untriaged
    • 1
    • Unknown

    Description

      UPSERT INTO default values("k001",{"arr":[{"x":1}, {"x":2}, {"x":1}, {"x":1}]});
      CREATE INDEX aix1 ON default(ALL ARRAY u.x FOR u IN arr END);
      CREATE INDEX aix1e ON default(ALL ARRAY u.x FOR u IN arr END, arr);

       

      The following query returns right results

       

      SELECT u.x
      FROM default AS d USE INDEX (aix1)
      UNNEST d.arr AS u
      WHERE u.x > 0
      ORDER BY u.x;
      results
         [
          { "x": 1 },
          { "x": 1 },
          { "x": 1 },
          { "x": 2 }
         ]
      

       

      The following query returns wrong results. The results should be same as above

       

       

      SELECT u.x, d.c1
      FROM default AS d USE INDEX (aix1)
      UNNEST d.arr AS u
      WHERE u.x > 0
      ORDER BY u.x;
      results
          [
          { "x": 1 },
          { "x": 2 },
          { "x": 1 },
          { "x": 1 }
          ]
      

       

       

       

      SELECT u.x
      FROM default AS d USE INDEX (aix1e)
      UNNEST d.arr AS u
      WHERE u.x > 0
      ORDER BY u.x;
      results
         [
          { "x": 1 },
          { "x": 1 },
          { "x": 1 },
          { "x": 1 }
         ]
      

       

       

       

      Attachments

        For Gerrit Dashboard: MB-51410
        # Subject Branch Project Status CR V

        Activity

          People

            ajay.bhullar Ajay Bhullar
            Sitaram.Vemulapalli Sitaram Vemulapalli
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes

                PagerDuty