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

Feature Request - ARRAY_INTERSECTION for N1QL

    XMLWordPrintable

Details

    • Improvement
    • Resolution: Fixed
    • Major
    • 4.5.1, 5.0.0
    • 4.1.1
    • query
    • None

    Description

      Currently many of the ARRAY functions only support atomic objects/single values as the second parameter. The request is to add array support for the second parameter in the ARRAY functions, specifically a new function potentially called ARRAY_INTERSECTION which would return True/False as a return code, and/or preferably the intersection array as the response data. If there were no elements in the second parameter array within the first parameter array, return false/empty array. Otherwise return the array which contains the values that exist in both input arrays. The ask is also to provide second parameter array support for ARRAY_REMOVE, ARRAY_APPEND, and other similar ARRAY functions.

      Example N1QL:

      SELECT fruits, vegetables, singlefruit, singlevegetable,
      ARRAY_INTERSECTION(fruits, singlefruit) AS ztest1,
      ARRAY_INTERSECTION(fruits, singlevegetable) AS ztest2,
      ARRAY_INTERSECTION(fruits, vegetables) AS ztest3
      FROM default b USE KEYS ["<single key>"]

      LET
      fruits = ARRAY_APPEND(ARRAY_APPEND(TOARRAY("apple"), "pear"), "tomato"),
      vegetables = ARRAY_APPEND(ARRAY_APPEND(TOARRAY("radish"), "broccoli"), "tomato"),
      singlefruit = "apple",
      singlevegetable = "tomato"

      Example Output:

      [

      { "fruits": [ "apple", "pear", "tomato" ], "singlefruit": "apple", "singlevegetable": "tomato", "vegetables": [ "radish", "broccoli", "tomato" ], "ztest1": true, "ztest2": true, "ztest3": false }

      ]

      Attachments

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

        Activity

          People

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