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

[6.6.6][N1QL] indexing MISSING when array subscript > 0

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Critical
    • 6.6.6
    • 6.6.6
    • query
    • 6.6.6-10566
    • Untriaged
    • 0
    • Yes

    Description

      simple repro

      create bucket named default

      load this doc

       {
            "VMs": [
              {
                "RAM": 10,
                "memory": 10,
                "name": "vm_10",
                "os": "ubuntu"
              },
              {
                "RAM": 10,
                "memory": 10,
                "name": "vm_11",
                "os": "windows"
              }
            ],
            "_id": "query-testemployee10153.1877827-0",
            "email": "9-mail@couchbase.com",
            "job_title": "Engineer",
            "join_day": 9,
            "join_mo": 10,
            "join_yr": 2011,
            "mutated": 0,
            "name": "employee-9",
            "skills": [
              "skill2010",
              "skill2011"
            ],
            "tasks_points": {
              "task1": 1,
              "task2": 1
            },
            "test_rate": 10.1
          }
      

      create primary index

      run this query
      select GREATEST(skills[0],skills[1]) from default where name = 'employee-9' and skills[0]='skill2010'

      we see that skills2011 is returned

      now create this index
      CREATE INDEX idx1 ON default(name,skills[0], skills[1])

      run query again

      we see that skills2010 is returned instead now

      explain for select GREATEST(skills[0],skills[1]) from default where name = 'employee-9' and skills[0]='skill2010' when using secondary index

      {
          "#operator": "Sequence",
          "~children": [
              {
                  "#operator": "IndexScan3",
                  "covers": [
                      "cover ((`default`.`name`))",
                      "cover (((`default`.`skills`)[0]))",
                      "cover (((`default`.`skills`)[1]))",
                      "cover ((meta(`default`).`id`))"
                  ],
                  "index": "idx1",
                  "index_id": "9493cf56d3b29b66",
                  "index_projection": {
                      "entry_keys": [
                          0,
                          1,
                          2
                      ]
                  },
                  "keyspace": "default",
                  "namespace": "default",
                  "spans": [
                      {
                          "exact": true,
                          "range": [
                              {
                                  "high": "\"employee-9\"",
                                  "inclusion": 3,
                                  "low": "\"employee-9\""
                              },
                              {
                                  "high": "\"skill2010\"",
                                  "inclusion": 3,
                                  "low": "\"skill2010\""
                              }
                          ]
                      }
                  ],
                  "using": "gsi"
              },
              {
                  "#operator": "Parallel",
                  "~child": {
                      "#operator": "Sequence",
                      "~children": [
                          {
                              "#operator": "Filter",
                              "condition": "((cover ((`default`.`name`)) = \"employee-9\") and (cover (((`default`.`skills`)[0])) = \"skill2010\"))"
                          },
                          {
                              "#operator": "InitialProject",
                              "result_terms": [
                                  {
                                      "expr": "greatest(cover (((`default`.`skills`)[0])), cover (((`default`.`skills`)[1])))"
                                  }
                              ]
                          },
                          {
                              "#operator": "FinalProject"
                          }
                      ]
                  }
              }
          ]
      }
      

      i can't see if this issue exists in 6.6.5 or not (there is one failure in that test in 6.6.5 but the logs appear to be gone for those runs) however in 6.6.4 the failure does not appear to happen.

      Attachments

        Issue Links

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

          Activity

            People

              ajay.bhullar Ajay Bhullar
              ajay.bhullar Ajay Bhullar
              Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes

                  PagerDuty