title | titleSuffix | description | author | ms.author | ms.reviewer | ms.service | ms.subservice | ms.topic | ms.devlang | ms.date | ms.custom |
---|---|---|---|---|---|---|---|---|---|---|---|
SetUnion |
Azure Cosmos DB for NoSQL |
An Azure Cosmos DB for NoSQL system function that gets all expressions in two sets. |
jcodella |
jacodel |
sidandrews |
cosmos-db |
nosql |
reference |
nosql |
02/27/2024 |
query-reference |
[!INCLUDENoSQL]
Gathers expressions in two sets and returns a set of expressions containing all expressions in both sets with no duplicates.
SetUnion(<array_expr_1>, <array_expr_2>)
Description | |
---|---|
array_expr_1 |
An array of expressions. |
array_expr_2 |
An array of expressions. |
Returns an array of expressions.
This first example uses the function with static arrays to demonstrate the union functionality.
:::code language="nosql" source="~/cosmos-db-nosql-query-samples/scripts/setunion/query.novalidate.sql" highlight="2-5":::
:::code language="json" source="~/cosmos-db-nosql-query-samples/scripts/setunion/result.novalidate.json":::
This last example uses an item that share values within multiple array properties.
:::code language="json" source="~/cosmos-db-nosql-query-samples/scripts/setunion-field/seed.novalidate.json" range="1-2,4-26" highlight="5-23":::
The query returns the union of the two arrays as a new property.
:::code language="nosql" source="~/cosmos-db-nosql-query-samples/scripts/setunion-field/query.novalidate.sql" highlight="3":::
:::code language="json" source="~/cosmos-db-nosql-query-samples/scripts/setunion-field/result.novalidate.json":::
- This function doesn't return duplicates.
- This function doesn't use the index.