Skip to content

Commit 245489c

Browse files
authored
Merge pull request #246033 from seesharprun/cosmos-populate-nosql-7
Cosmos DB | Add NoSQL query functions #9
2 parents 1d8ae1c + b345f7a commit 245489c

File tree

10 files changed

+158
-351
lines changed

10 files changed

+158
-351
lines changed

articles/cosmos-db/nosql/query/setintersect.md

Lines changed: 11 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ ms.reviewer: sidandrews
88
ms.service: cosmos-db
99
ms.subservice: nosql
1010
ms.topic: reference
11-
ms.date: 07/01/2023
11+
ms.date: 07/24/2023
1212
ms.custom: query-reference
1313
---
1414

@@ -39,71 +39,24 @@ Returns an array of expressions.
3939

4040
This first example uses the function with static arrays to demonstrate the intersect functionality.
4141

42-
```sql
43-
SELECT VALUE {
44-
simpleIntersect: SetIntersect([1, 2, 3, 4], [3, 4, 5, 6]),
45-
emptyIntersect: SetIntersect([1, 2, 3, 4], []),
46-
duplicatesIntersect: SetIntersect([1, 2, 3, 4], [1, 1, 1, 1]),
47-
noMatchesIntersect: SetIntersect([1, 2, 3, 4], ["A", "B"]),
48-
unorderedIntersect: SetIntersect([1, 2, "A", "B"], ["A", 1])
49-
}
50-
```
42+
:::code language="sql" source="~/cosmos-db-nosql-query-samples/scripts/setintersect/query.novalidate.sql" highlight="2-6":::
5143

52-
```json
53-
[
54-
{
55-
"simpleIntersect": [3, 4],
56-
"emptyIntersect": [],
57-
"duplicatesIntersect": [1],
58-
"noMatchesIntersect": [],
59-
"unorderedIntersect": ["A", 1]
60-
}
61-
]
62-
```
44+
:::code language="json" source="~/cosmos-db-nosql-query-samples/scripts/setintersect/result.novalidate.json":::
6345

64-
This last example uses two items in a container that share values within an array property.
65-
66-
```json
67-
[
68-
{
69-
"name": "Snowilla Women's Vest",
70-
"inStockColors": [
71-
"Rhino",
72-
"Finch"
73-
],
74-
"colors": [
75-
"Finch",
76-
"Mine Shaft",
77-
"Rhino"
78-
]
79-
}
80-
]
81-
```
46+
This last example uses a single item that share values within two array properties.
8247

83-
```sql
84-
SELECT
85-
p.name,
86-
SetIntersect(p.colors, p.inStockColors) AS availableColors
87-
FROM
88-
products p
89-
```
48+
:::code language="json" source="~/cosmos-db-nosql-query-samples/scripts/setintersect-field/seed.novalidate.json" range="1-2,4-16" highlight="4-12":::
9049

91-
```json
92-
[
93-
{
94-
"name": "Snowilla Women's Vest",
95-
"availableColors": [
96-
"Rhino",
97-
"Finch"
98-
]
99-
}
100-
]
101-
```
50+
The query selects the appropriate field from the item\[s\] in the container.
51+
52+
:::code language="sql" source="~/cosmos-db-nosql-query-samples/scripts/setintersect-field/query.novalidate.sql" highlight="3":::
53+
54+
:::code language="json" source="~/cosmos-db-nosql-query-samples/scripts/setintersect-field/result.novalidate.json":::
10255

10356
## Remarks
10457

10558
- This function doesn't return duplicates.
106-
- This function doesn't utilize the index.
59+
- This function doesn't use the index.
10760

10861
## See also
10962

articles/cosmos-db/nosql/query/setunion.md

Lines changed: 11 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ ms.reviewer: sidandrews
88
ms.service: cosmos-db
99
ms.subservice: nosql
1010
ms.topic: reference
11-
ms.date: 07/01/2023
11+
ms.date: 07/24/2023
1212
ms.custom: query-reference
1313
---
1414

@@ -39,82 +39,24 @@ Returns an array of expressions.
3939

4040
This first example uses the function with static arrays to demonstrate the union functionality.
4141

42-
```sql
43-
SELECT VALUE {
44-
simpleUnion: SetUnion([1, 2, 3, 4], [3, 4, 5, 6]),
45-
emptyUnion: SetUnion([1, 2, 3, 4], []),
46-
duplicatesUnion: SetUnion([1, 2, 3, 4], [1, 1, 1, 1]),
47-
unorderedUnion: SetUnion([1, 2, "A", "B"], ["A", 1])
48-
}
49-
```
42+
:::code language="sql" source="~/cosmos-db-nosql-query-samples/scripts/setunion/query.novalidate.sql" highlight="2-5":::
5043

51-
```json
52-
[
53-
{
54-
"simpleUnion": [1, 2, 3, 4, 5, 6],
55-
"emptyUnion": [1, 2, 3, 4],
56-
"duplicatesUnion": [1, 2, 3, 4],
57-
"unorderedUnion": [1, 2, "A", "B"]
58-
}
59-
]
60-
```
44+
:::code language="json" source="~/cosmos-db-nosql-query-samples/scripts/setunion/result.novalidate.json":::
6145

62-
This last example uses two items in a container that share values within an array property.
63-
64-
```json
65-
[
66-
{
67-
"name": "Yarbeck Men's Coat",
68-
"colors": [
69-
{
70-
"season": "Winter",
71-
"values": [
72-
"Cutty Sark",
73-
"Horizon",
74-
"Russet",
75-
"Fuscous"
76-
]
77-
},
78-
{
79-
"season": "Summer",
80-
"values": [
81-
"Fuscous",
82-
"Horizon",
83-
"Tacha"
84-
]
85-
}
86-
]
87-
}
88-
]
89-
```
46+
This last example uses an item that share values within multiple array properties.
9047

91-
```sql
92-
SELECT
93-
p.name,
94-
SetUnion(p.colors[0].values, p.colors[1].values) AS allColors
95-
FROM
96-
products p
97-
```
48+
:::code language="json" source="~/cosmos-db-nosql-query-samples/scripts/setunion-field/seed.novalidate.json" range="1-2,4-26" highlight="5-23":::
9849

99-
```json
100-
[
101-
{
102-
"name": "Yarbeck Men's Coat",
103-
"allColors": [
104-
"Cutty Sark",
105-
"Horizon",
106-
"Russet",
107-
"Fuscous",
108-
"Tacha"
109-
]
110-
}
111-
]
112-
```
50+
The query returns the union of the two arrays as a new property.
51+
52+
:::code language="sql" source="~/cosmos-db-nosql-query-samples/scripts/setunion-field/query.novalidate.sql" highlight="3":::
53+
54+
:::code language="json" source="~/cosmos-db-nosql-query-samples/scripts/setunion-field/result.novalidate.json":::
11355

11456
## Remarks
11557

11658
- This function doesn't return duplicates.
117-
- This function doesn't utilize the index.
59+
- This function doesn't use the index.
11860

11961
## See also
12062

Lines changed: 33 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,52 @@
11
---
2-
title: SIGN in Azure Cosmos DB query language
3-
description: Learn about SQL system function SIGN in Azure Cosmos DB.
4-
author: ginamr
2+
title: SIGN
3+
titleSuffix: Azure Cosmos DB for NoSQL
4+
description: An Azure Cosmos DB for NoSQL system function that returns the sign of the specified number.
5+
author: jcodella
6+
ms.author: jacodel
7+
ms.reviewer: sidandrews
58
ms.service: cosmos-db
69
ms.subservice: nosql
7-
ms.topic: conceptual
8-
ms.date: 03/03/2020
9-
ms.author: girobins
10-
ms.custom: query-reference, ignite-2022
10+
ms.topic: reference
11+
ms.date: 07/24/2023
12+
ms.custom: query-reference
1113
---
12-
# SIGN (Azure Cosmos DB)
14+
15+
# SIGN (NoSQL query)
16+
1317
[!INCLUDE[NoSQL](../../includes/appliesto-nosql.md)]
1418

15-
Returns the positive (+1), zero (0), or negative (-1) sign of the specified numeric expression.
16-
19+
Returns the positive (+1), zero (0), or negative (-1) sign of the specified numeric expression.
20+
1721
## Syntax
18-
22+
1923
```sql
2024
SIGN(<numeric_expr>)
21-
```
22-
25+
```
26+
2327
## Arguments
24-
25-
*numeric_expr*
26-
Is a numeric expression.
27-
28+
29+
| | Description |
30+
| --- | --- |
31+
| **`numeric_expr`** | A numeric expression. |
32+
2833
## Return types
29-
30-
Returns a numeric expression.
31-
34+
35+
Returns a numeric expression.
36+
3237
## Examples
33-
34-
The following example returns the `SIGN` values of numbers from -2 to 2.
35-
36-
```sql
37-
SELECT SIGN(-2) AS s1, SIGN(-1) AS s2, SIGN(0) AS s3, SIGN(1) AS s4, SIGN(2) AS s5
38-
```
39-
40-
Here is the result set.
41-
42-
```json
43-
[{s1: -1, s2: -1, s3: 0, s4: 1, s5: 1}]
44-
```
38+
39+
The following example returns the sign of various numbers from -2 to 2.
40+
41+
:::code language="sql" source="~/cosmos-db-nosql-query-samples/scripts/sign/query.sql" highlight="2-6":::
42+
43+
:::code language="json" source="~/cosmos-db-nosql-query-samples/scripts/sign/result.json":::
4544

4645
## Remarks
4746

48-
This system function will not utilize the index.
47+
- This function doesn't use the index.
4948

5049
## Next steps
5150

5251
- [System functions Azure Cosmos DB](system-functions.yml)
53-
- [Introduction to Azure Cosmos DB](../../introduction.md)
52+
- [`ABS`](abs.md)

articles/cosmos-db/nosql/query/sin.md

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ ms.reviewer: sidandrews
88
ms.service: cosmos-db
99
ms.subservice: nosql
1010
ms.topic: reference
11-
ms.date: 07/01/2023
11+
ms.date: 07/24/2023
1212
ms.custom: query-reference
1313
---
1414

@@ -22,7 +22,7 @@ Returns the trigonometric sine of the specified angle in radians.
2222

2323
```sql
2424
SIN(<numeric_expr>)
25-
```
25+
```
2626

2727
## Arguments
2828

@@ -38,23 +38,13 @@ Returns a numeric expression.
3838

3939
The following example calculates the sine of the specified angle using the function.
4040

41-
```sql
42-
SELECT VALUE {
43-
sine: SIN(45.175643)
44-
}
45-
```
46-
47-
```json
48-
[
49-
{
50-
"sine": 0.929607286611012
51-
}
52-
]
53-
```
41+
:::code language="sql" source="~/cosmos-db-nosql-query-samples/scripts/sin/query.sql" highlight="2":::
42+
43+
:::code language="json" source="~/cosmos-db-nosql-query-samples/scripts/sin/result.json":::
5444

5545
## Remarks
5646

57-
- This system function doesn't utilize the index.
47+
- This function doesn't use the index.
5848

5949
## Next steps
6050

articles/cosmos-db/nosql/query/sqrt.md

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -38,34 +38,16 @@ Returns a numeric expression.
3838

3939
The following example returns the square roots of various numeric values.
4040

41-
```sql
42-
SELECT VALUE {
43-
sqrtZero: SQRT(0),
44-
sqrtOne: SQRT(1),
45-
sqrtFour: SQRT(4),
46-
sqrtPrime: SQRT(17),
47-
sqrtTwentyFive: SQRT(25)
48-
}
49-
```
50-
51-
```json
52-
[
53-
{
54-
"sqrtZero": 0,
55-
"sqrtOne": 1,
56-
"sqrtFour": 2,
57-
"sqrtPrime": 4.123105625617661,
58-
"sqrtTwentyFive": 5
59-
}
60-
]
61-
```
41+
:::code language="sql" source="~/cosmos-db-nosql-query-samples/scripts/sqrt/query.sql" highlight="2-6":::
42+
43+
:::code language="json" source="~/cosmos-db-nosql-query-samples/scripts/sqrt/result.json":::
6244

6345
## Remarks
6446

65-
- This system function doesn't utilize the index.
47+
- This function doesn't use the index.
6648
- If you attempt to find the square root value that results in an imaginary number, you get an error that the value can't be represented in JSON. For example, `SQRT(-25)` gives this error.
6749

6850
## Next steps
6951

7052
- [System functions Azure Cosmos DB](system-functions.yml)
71-
- [Introduction to Azure Cosmos DB](../../introduction.md)
53+
- [`POWER`](power.md)

0 commit comments

Comments
 (0)