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

Incorrect aggregate results from index

    XMLWordPrintable

Details

    • Untriaged
    • 1
    • Unknown

    Description

      Repro:

       

      insert into default (key,value) values("e::g::1",{"type":"SUPPORTAL::snapshot","nodes":[{"results":{"checker_list":["Data Quota"]}},{"results":{"checker_list":["Data Quota"]}}]});
       
      insert into default (key,value) values("e::g::2",{"type":"SUPPORTAL::snapshot","nodes":[{"results":{"checker_list":["Data Quota"]}},{"results":{"checker_list":["Data Quota"]}}]});
       
      insert into default (key,value) values("e::g::3::0",{"type":"SUPPORTAL::snapshot","nodes":[{"results":{"checker_list":["Data Quota"]}},{"results":{"checker_list":["Data Quota"]}}]});
       
      CREATE INDEX TESTING_INDEX ON `default`(`type`) WHERE ((`type` = 'SUPPORTAL::snapshot') and (array_intersect(array_flatten((array_star((array_star(`nodes`).`results`)).`checker_list`), 1), ['Data Quota', 'FTS Quota', 'Index Quota', 'Analytics Quota', 'Eventing Quota']) = ['Data Quota']));

      The following two queries should produce the same results:

      SELECT RAW SPLIT(META().id, "::")[2] FROM default WHERE type = "SUPPORTAL::snapshot" AND ARRAY_INTERSECT(ARRAY_FLATTEN(nodes[*].results[*].checker_list, 1), ["Data Quota", "FTS Quota", "Index Quota", "Analytics Quota", "Eventing Quota"]) = ["Data Quota"] GROUP BY SPLIT(META().id, "::")[2];
       
      SELECT SPLIT(META().id, "::")[2] FROM default WHERE type = "SUPPORTAL::snapshot" AND ARRAY_INTERSECT(ARRAY_FLATTEN(nodes[*].results[*].checker_list, 1), ["Data Quota", "FTS Quota", "Index Quota", "Analytics Quota", "Eventing Quota"]) = ["Data Quota"] and SPLIT(META().id, "::")[2] is not null GROUP BY SPLIT(META().id, "::")[2];
      

      as the only difference is the "SPLIT(META().id, "::")[2] is not null" clause and since SPLIT(META().id, "::")[2] is not null (see data) it should make no difference.

      The first returns only one result instead of the 3 it should.

      Of course in the plan, the first shows:

                          "index": "TESTING_INDEX",
                          "index_group_aggs": {
                              "depends": [
                                  1
                              ],
                              "group": [
                                  {
                                      "depends": [
                                          1
                                      ],
                                      "expr": "(split(cover ((meta(`default`).`id`)), \"::\")[2])",
                                      "id": 2,
                                      "keypos": -1
                                  }
                              ],
                              "partial": true
                          },
      

      whereas the latter doesn't (and processes it as a filter).

      So it appears the results from the index group aggregate are truncated.

       

       

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            hemant.rajput Hemant Rajput
            Donald.haggart Donald Haggart
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes

                PagerDuty