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

[N1QL Explain Plan] Plan has changed for query with unnest under tokens test suite

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Major
    • 4.6.3, 5.0.0
    • 5.0.0
    • query
    • 5.0.0-3453,5.0.0-3456
    • Untriaged
    • Yes

    Description

      Test which fails:
      ./testrunner -i query7.ini -t tuqquery.tuq_tokens.TokenTests.test_tokens_simple_syntax,default_bucket=False

      What the test does?
      1. Load beer-sample bucket.
      2. Indexes generated by test:
      CREATE INDEX `idx22` ON `beer-sample`((distinct (array `v` for `v` in tokens(`description`,

      {"specials": "random"}

      ) end)))

      CREATE INDEX `idx_addresses` ON `beer-sample`((all (`address`)))

      CREATE INDEX `idx_pairs` ON `beer-sample`((distinct (pairs(self))))

      CREATE INDEX `idx_suffixes` ON `beer-sample`((distinct (suffixes(`name`))))

      CREATE INDEX `idx_tokens` ON `beer-sample`((distinct (tokens(`description`))))

      3. Query issued:
      explain select min(addr) from `beer-sample` unnest address as addr;

      Explain plan generated:

      [
        {
          "plan": {
            "#operator": "Sequence",
            "~children": [
              {
                "#operator": "IntersectScan",
                "scans": [
                  {
                    "#operator": "DistinctScan",
                    "scan": {
                      "#operator": "IndexScan2",
                      "index": "idx_suffixes",
                      "index_id": "a346d30f9f9ae866",
                      "index_projection": {
                        "primary_key": true
                      },
                      "keyspace": "beer-sample",
                      "namespace": "default",
                      "spans": [
                        {
                          "exact": true,
                          "range": [
                            {
                              "inclusion": 0,
                              "low": "null"
                            }
                          ]
                        }
                      ],
                      "using": "gsi"
                    }
                  },
                  {
                    "#operator": "DistinctScan",
                    "scan": {
                      "#operator": "IndexScan2",
                      "index": "idx_pairs",
                      "index_id": "d5c259d33085fe13",
                      "index_projection": {
                        "primary_key": true
                      },
                      "keyspace": "beer-sample",
                      "namespace": "default",
                      "spans": [
                        {
                          "exact": true,
                          "range": [
                            {
                              "inclusion": 0,
                              "low": "null"
                            }
                          ]
                        }
                      ],
                      "using": "gsi"
                    }
                  },
                  {
                    "#operator": "DistinctScan",
                    "scan": {
                      "#operator": "IndexScan2",
                      "index": "idx_addresses",
                      "index_id": "3acacafce10f02f2",
                      "index_projection": {
                        "primary_key": true
                      },
                      "keyspace": "beer-sample",
                      "namespace": "default",
                      "spans": [
                        {
                          "exact": true,
                          "range": [
                            {
                              "inclusion": 0,
                              "low": "null"
                            }
                          ]
                        }
                      ],
                      "using": "gsi"
                    }
                  },
                  {
                    "#operator": "DistinctScan",
                    "scan": {
                      "#operator": "IndexScan2",
                      "index": "idx_tokens",
                      "index_id": "3dad88fff71a42c",
                      "index_projection": {
                        "primary_key": true
                      },
                      "keyspace": "beer-sample",
                      "namespace": "default",
                      "spans": [
                        {
                          "exact": true,
                          "range": [
                            {
                              "inclusion": 0,
                              "low": "null"
                            }
                          ]
                        }
                      ],
                      "using": "gsi"
                    }
                  },
                  {
                    "#operator": "DistinctScan",
                    "scan": {
                      "#operator": "IndexScan2",
                      "index": "idx_pairs",
                      "index_id": "d5c259d33085fe13",
                      "index_projection": {
                        "primary_key": true
                      },
                      "keyspace": "beer-sample",
                      "namespace": "default",
                      "spans": [
                        {
                          "exact": true,
                          "range": [
                            {
                              "high": "[successor(\"address\")]",
                              "inclusion": 1,
                              "low": "[\"address\", []]"
                            }
                          ]
                        }
                      ],
                      "using": "gsi"
                    }
                  },
                  {
                    "#operator": "DistinctScan",
                    "scan": {
                      "#operator": "IndexScan2",
                      "index": "idx_pairs",
                      "index_id": "d5c259d33085fe13",
                      "index_projection": {
                        "primary_key": true
                      },
                      "keyspace": "beer-sample",
                      "namespace": "default",
                      "spans": [
                        {
                          "exact": true,
                          "range": [
                            {
                              "high": "[\"address\", {}]",
                              "inclusion": 1,
                              "low": "[\"address\", false]"
                            }
                          ]
                        }
                      ],
                      "using": "gsi"
                    }
                  },
                  {
                    "#operator": "DistinctScan",
                    "scan": {
                      "#operator": "IndexScan2",
                      "index": "idx_pairs",
                      "index_id": "d5c259d33085fe13",
                      "index_projection": {
                        "primary_key": true
                      },
                      "keyspace": "beer-sample",
                      "namespace": "default",
                      "spans": [
                        {
                          "exact": true,
                          "range": [
                            {
                              "high": "[successor(\"addr\")]",
                              "inclusion": 1,
                              "low": "[\"addr\", false]"
                            }
                          ]
                        }
                      ],
                      "using": "gsi"
                    }
                  },
                  {
                    "#operator": "DistinctScan",
                    "scan": {
                      "#operator": "IndexScan2",
                      "index": "idx_pairs",
                      "index_id": "d5c259d33085fe13",
                      "index_projection": {
                        "primary_key": true
                      },
                      "keyspace": "beer-sample",
                      "namespace": "default",
                      "spans": [
                        {
                          "exact": true,
                          "range": [
                            {
                              "inclusion": 0,
                              "low": "null"
                            }
                          ]
                        }
                      ],
                      "using": "gsi"
                    }
                  }
                ]
              },
              {
                "#operator": "Fetch",
                "keyspace": "beer-sample",
                "namespace": "default"
              },
              {
                "#operator": "Parallel",
                "~child": {
                  "#operator": "Sequence",
                  "~children": [
                    {
                      "#operator": "Unnest",
                      "as": "addr",
                      "expr": "(`beer-sample`.`address`)"
                    }
                  ]
                }
              },
              {
                "#operator": "Parallel",
                "~child": {
                  "#operator": "Sequence",
                  "~children": [
                    {
                      "#operator": "InitialGroup",
                      "aggregates": [
                        "min(`addr`)"
                      ],
                      "group_keys": []
                    }
                  ]
                }
              },
              {
                "#operator": "IntermediateGroup",
                "aggregates": [
                  "min(`addr`)"
                ],
                "group_keys": []
              },
              {
                "#operator": "FinalGroup",
                "aggregates": [
                  "min(`addr`)"
                ],
                "group_keys": []
              },
              {
                "#operator": "Parallel",
                "~child": {
                  "#operator": "Sequence",
                  "~children": [
                    {
                      "#operator": "InitialProject",
                      "result_terms": [
                        {
                          "expr": "min(`addr`)"
                        }
                      ]
                    },
                    {
                      "#operator": "FinalProject"
                    }
                  ]
                }
              }
            ]
          },
          "text": "select min(addr) from `beer-sample` unnest address as addr;"
        }
      ]
       
      
      

      4. Above explain plan is different from previous runs. This could be the result of unnest changes.
      5. Assert which fails:
      https://github.com/couchbase/testrunner/blob/master/pytests/tuqquery/tuq_tokens.py#L248
      self.assertTrue(plan['~children'][0]['index']==idx4)
      where idx4 = idx_addresses

      Attachments

        Issue Links

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

          Activity

            People

              Prerna.Manaktala Prerna Manaktala (Inactive)
              Prerna.Manaktala Prerna Manaktala (Inactive)
              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