Skip to content

Latest commit

 

History

History
65 lines (43 loc) · 1.85 KB

setunion.md

File metadata and controls

65 lines (43 loc) · 1.85 KB
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

SetUnion (NoSQL query)

[!INCLUDENoSQL]

Gathers expressions in two sets and returns a set of expressions containing all expressions in both sets with no duplicates.

Syntax

SetUnion(<array_expr_1>, <array_expr_2>)

Arguments

Description
array_expr_1 An array of expressions.
array_expr_2 An array of expressions.

Return types

Returns an array of expressions.

Examples

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":::

Remarks

  • This function doesn't return duplicates.
  • This function doesn't use the index.

See also