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

[N1QL] ansi join query no longer valid

    XMLWordPrintable

Details

    • Bug
    • Resolution: Not a Bug
    • Major
    • 7.1.0
    • 7.1.0
    • query
    • None
    • 7.1.0-1831
    • Untriaged
    • 1
    • Yes

    Description

      Is the query below no longer valid in 7.1? I see that it works in 7.x
      I have a default bucket and travel-sample

      CREATE PRIMARY INDEX ON default
      CREATE INDEX id ON `travel-sample`(id)

      SELECT *
      FROM default d
      INNER JOIN `travel-sample` t ON (t.id IN (DISTINCT ARRAY v.RAM FOR v IN d.VMs END))

      [

      { "code": 3284, "msg": "ALL/DISTINCT is not allowed in (distinct (array (`v`.`RAM`) for `v` in (`d`.`VMs`) end)).", "query": "SELECT *\nFROM default d\nINNER JOIN `travel-sample` t ON (t.id IN (DISTINCT ARRAY v.RAM FOR v IN d.VMs END))" }

      ]

      In 7.0.x we see that this query works and returns results
      EXPLAIN SELECT *
      FROM default d
      INNER JOIN `travel-sample` t ON (t.id IN (DISTINCT ARRAY v.RAM FOR v IN d.VMs END))

      {
          "#operator": "Sequence",
          "~children": [
              {
                  "#operator": "PrimaryScan3",
                  "as": "d",
                  "index": "#primary",
                  "index_projection": {
                      "primary_key": true
                  },
                  "keyspace": "default",
                  "namespace": "default",
                  "using": "gsi"
              },
              {
                  "#operator": "Fetch",
                  "as": "d",
                  "keyspace": "default",
                  "namespace": "default"
              },
              {
                  "#operator": "Parallel",
                  "~child": {
                      "#operator": "Sequence",
                      "~children": [
                          {
                              "#operator": "NestedLoopJoin",
                              "alias": "t",
                              "on_clause": "((`t`.`id`) in (distinct (array (`v`.`RAM`) for `v` in (`d`.`VMs`) end)))",
                              "~child": {
                                  "#operator": "Sequence",
                                  "~children": [
                                      {
                                          "#operator": "IndexScan3",
                                          "as": "t",
                                          "has_dynamic_in": true,
                                          "index": "id",
                                          "index_id": "3d45b18547e1a1c2",
                                          "index_projection": {
                                              "primary_key": true
                                          },
                                          "keyspace": "travel-sample",
                                          "namespace": "default",
                                          "nested_loop": true,
                                          "spans": [
                                              {
                                                  "range": [
                                                      {
                                                          "dynamic_in": true,
                                                          "high": "array_max((distinct (array (`v`.`RAM`) for `v` in (`d`.`VMs`) end)))",
                                                          "inclusion": 3,
                                                          "low": "array_min((distinct (array (`v`.`RAM`) for `v` in (`d`.`VMs`) end)))"
                                                      }
                                                  ]
                                              }
                                          ],
                                          "using": "gsi"
                                      },
                                      {
                                          "#operator": "Fetch",
                                          "as": "t",
                                          "keyspace": "travel-sample",
                                          "namespace": "default",
                                          "nested_loop": true
                                      }
                                  ]
                              }
                          },
                          {
                              "#operator": "InitialProject",
                              "result_terms": [
                                  {
                                      "expr": "self",
                                      "star": true
                                  }
                              ]
                          }
                      ]
                  }
              }
          ]
      }
      

      Attachments

        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:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes

                PagerDuty