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 }]