I’m trying to write a cosmos query that return a list of ids, which contain duplicates in a string array that exists on each record.
Here’s an example of the dataset I’m working with. using this data, only the id of A and B should be returned as their “things” array contains at least one duplicate strings.
[
{
"id": "A",
"things": [
"1",
"1",
"2",
"2",
"3"
]
},
{
"id": "B",
"things": [
"1",
"1",
"2",
"3"
]
},
{
"id": "C",
"things": [
"1",
"2",
"3"
]
}
]
I’ve tried to use a subquery, but can’t seem to get that to work.
user2835238 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
3
I was able to get around this by writing a udf to check for duplicates in the string array.
SELECT
c.id,
FROM c
WHERE
udf.isDuplicate(c.things) = true
user2835238 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.