Skip to content

Commit 98b6db6

Browse files
authored
Merge pull request #245668 from seesharprun/cosmos-populate-nosql-5
Cosmos DB | Add NoSQL query functions #7
2 parents dbbe356 + 8b02bfd commit 98b6db6

File tree

10 files changed

+169
-319
lines changed

10 files changed

+169
-319
lines changed

articles/cosmos-db/nosql/query/is-array.md

Lines changed: 5 additions & 31 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/20/2023
1212
ms.custom: query-reference
1313
---
1414

@@ -38,39 +38,13 @@ Returns a boolean expression.
3838

3939
The following example checks objects of various types using the function.
4040

41-
```sql
42-
SELECT VALUE {
43-
booleanIsArray: IS_ARRAY(true),
44-
numberIsArray: IS_ARRAY(65),
45-
stringIsArray: IS_ARRAY("AdventureWorks"),
46-
nullIsArray: IS_ARRAY(null),
47-
objectIsArray: IS_ARRAY({size: "small"}),
48-
arrayIsArray: IS_ARRAY([25344, 82947]),
49-
arrayObjectPropertyIsArray: IS_ARRAY({skus: [25344, 82947], vendors: null}.skus),
50-
invalidObjectPropertyIsArray: IS_ARRAY({skus: [25344, 82947], vendors: null}.size),
51-
nullObjectPropertyIsArray: IS_ARRAY({skus: [25344, 82947], vendors: null}.vendor)
52-
}
53-
```
54-
55-
```json
56-
[
57-
{
58-
"booleanIsArray": false,
59-
"numberIsArray": false,
60-
"stringIsArray": false,
61-
"nullIsArray": false,
62-
"objectIsArray": false,
63-
"arrayIsArray": true,
64-
"arrayObjectPropertyIsArray": true,
65-
"invalidObjectPropertyIsArray": false,
66-
"nullObjectPropertyIsArray": false
67-
}
68-
]
69-
```
41+
:::code language="sql" source="~/cosmos-db-nosql-query-samples/scripts/is-array/query.sql" highlight="2-10":::
42+
43+
:::code language="json" source="~/cosmos-db-nosql-query-samples/scripts/is-array/result.json":::
7044

7145
## Remarks
7246

73-
- This system function benefits from a [range index](../../index-policy.md#includeexclude-strategy).
47+
- This function benefits from a [range index](../../index-policy.md#includeexclude-strategy).
7448

7549
## Next steps
7650

articles/cosmos-db/nosql/query/is-bool.md

Lines changed: 5 additions & 31 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/20/2023
1212
ms.custom: query-reference
1313
---
1414

@@ -38,39 +38,13 @@ Returns a boolean expression.
3838

3939
The following example checks objects of various types using the function.
4040

41-
```sql
42-
SELECT VALUE {
43-
booleanIsBool: IS_BOOL(true),
44-
numberIsBool: IS_BOOL(65),
45-
stringIsBool: IS_BOOL("AdventureWorks"),
46-
nullIsBool: IS_BOOL(null),
47-
objectIsBool: IS_BOOL({size: "small"}),
48-
arrayIsBool: IS_BOOL([25344, 82947]),
49-
arrayObjectPropertyIsBool: IS_BOOL({skus: [25344, 82947], vendors: null}.skus),
50-
invalidObjectPropertyIsBool: IS_BOOL({skus: [25344, 82947], vendors: null}.size),
51-
nullObjectPropertyIsBool: IS_BOOL({skus: [25344, 82947], vendors: null}.vendor)
52-
}
53-
```
54-
55-
```json
56-
[
57-
{
58-
"booleanIsBool": true,
59-
"numberIsBool": false,
60-
"stringIsBool": false,
61-
"nullIsBool": false,
62-
"objectIsBool": false,
63-
"arrayIsBool": false,
64-
"arrayObjectPropertyIsBool": false,
65-
"invalidObjectPropertyIsBool": false,
66-
"nullObjectPropertyIsBool": false
67-
}
68-
]
69-
```
41+
:::code language="sql" source="~/cosmos-db-nosql-query-samples/scripts/is-bool/query.sql" highlight="2-10":::
42+
43+
:::code language="json" source="~/cosmos-db-nosql-query-samples/scripts/is-bool/result.json":::
7044

7145
## Remarks
7246

73-
- This system function benefits from a [range index](../../index-policy.md#includeexclude-strategy).
47+
- This function benefits from a [range index](../../index-policy.md#includeexclude-strategy).
7448

7549
## Next steps
7650

Lines changed: 30 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,52 @@
11
---
2-
title: IS_DEFINED in Azure Cosmos DB query language
3-
description: Learn about SQL system function IS_DEFINED in Azure Cosmos DB.
4-
author: ginamr
2+
title: IS_DEFINED
3+
titleSuffix: Azure Cosmos DB for NoSQL
4+
description: An Azure Cosmos DB for NoSQL system function that returns true if the property has been assigned a value.
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: 09/13/2019
9-
ms.author: girobins
10-
ms.custom: query-reference, ignite-2022
10+
ms.topic: reference
11+
ms.date: 07/20/2023
12+
ms.custom: query-reference
1113
---
12-
# IS_DEFINED (Azure Cosmos DB)
14+
15+
# IS_DEFINED (NoSQL query)
16+
1317
[!INCLUDE[NoSQL](../../includes/appliesto-nosql.md)]
1418

15-
Returns a Boolean indicating if the property has been assigned a value.
16-
19+
Returns a boolean indicating if the property has been assigned a value.
20+
1721
## Syntax
18-
22+
1923
```sql
2024
IS_DEFINED(<expr>)
2125
```
22-
26+
2327
## Arguments
24-
25-
*expr*
26-
Is any expression.
28+
29+
| | Description |
30+
| --- | --- |
31+
| **`expr`** | Any expression. |
2732

2833
## Return types
2934

30-
Returns a Boolean expression.
31-
35+
Returns a boolean expression.
36+
3237
## Examples
33-
34-
The following example checks for the presence of a property within the specified JSON document. The first returns true since "a" is present, but the second returns false since "b" is absent.
35-
36-
```sql
37-
SELECT IS_DEFINED({ "a" : 5 }.a) AS isDefined1, IS_DEFINED({ "a" : 5 }.b) AS isDefined2
38-
```
39-
40-
Here is the result set.
41-
42-
```json
43-
[{"isDefined1":true,"isDefined2":false}]
44-
```
38+
39+
The following example checks for the presence of a property within the specified JSON document.
40+
41+
:::code language="sql" source="~/cosmos-db-nosql-query-samples/scripts/is-defined/query.sql" highlight="2-3":::
42+
43+
:::code language="json" source="~/cosmos-db-nosql-query-samples/scripts/is-defined/result.json":::
4544

4645
## Remarks
4746

48-
This system function will benefit from a [range index](../../index-policy.md#includeexclude-strategy).
47+
- This function benefits from a [range index](../../index-policy.md#includeexclude-strategy).
4948

5049
## Next steps
5150

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

articles/cosmos-db/nosql/query/is-finite-number.md

Lines changed: 7 additions & 17 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/20/2023
1212
ms.custom: query-reference
1313
---
1414

@@ -38,23 +38,13 @@ Returns a boolean.
3838

3939
This example demonstrates the function with various static values.
4040

41-
```sql
42-
SELECT VALUE {
43-
finiteValue: IS_FINITE_NUMBER(1234.567),
44-
infiniteValue: IS_FINITE_NUMBER(8.9 / 0.0),
45-
nanValue: IS_FINITE_NUMBER(SQRT(-1.0))
46-
}
47-
```
41+
:::code language="sql" source="~/cosmos-db-nosql-query-samples/scripts/is-finite-number/query.sql" highlight="2-4":::
4842

49-
```json
50-
[
51-
{
52-
"finiteValue": true,
53-
"infiniteValue": false,
54-
"nanValue": false
55-
}
56-
]
57-
```
43+
:::code language="json" source="~/cosmos-db-nosql-query-samples/scripts/is-finite-number/result.json":::
44+
45+
## Remarks
46+
47+
- This function benefits from a [range index](../../index-policy.md#includeexclude-strategy).
5848

5949
## See also
6050

articles/cosmos-db/nosql/query/is-integer.md

Lines changed: 7 additions & 21 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/20/2023
1212
ms.custom: query-reference
1313
---
1414

@@ -38,27 +38,13 @@ Returns a boolean.
3838

3939
This example demonstrates the function with various static values.
4040

41-
```sql
42-
SELECT VALUE {
43-
smallDecimalValue: IS_INTEGER(3454.123),
44-
integerValue: IS_INTEGER(5523432),
45-
minIntegerValue: IS_INTEGER(-9223372036854775808),
46-
maxIntegerValue: IS_INTEGER(9223372036854775807),
47-
outOfRangeValue: IS_INTEGER(18446744073709551615)
48-
}
49-
```
41+
:::code language="sql" source="~/cosmos-db-nosql-query-samples/scripts/is-integer/query.sql" highlight="2-6":::
5042

51-
```json
52-
[
53-
{
54-
"smallDecimalValue": false,
55-
"integerValue": true,
56-
"minIntegerValue": true,
57-
"maxIntegerValue": true,
58-
"outOfRangeValue": false
59-
}
60-
]
61-
```
43+
:::code language="json" source="~/cosmos-db-nosql-query-samples/scripts/is-integer/result.json":::
44+
45+
## Remarks
46+
47+
- This function benefits from a [range index](../../index-policy.md#includeexclude-strategy).
6248

6349
## See also
6450

articles/cosmos-db/nosql/query/is-null.md

Lines changed: 5 additions & 31 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/20/2023
1212
ms.custom: query-reference
1313
---
1414

@@ -38,39 +38,13 @@ Returns a boolean expression.
3838

3939
The following example checks objects of various types using the function.
4040

41-
```sql
42-
SELECT VALUE {
43-
booleanIsNull: IS_NULL(true),
44-
numberIsNull: IS_NULL(15),
45-
stringIsNull: IS_NULL("AdventureWorks"),
46-
nullIsNull: IS_NULL(null),
47-
objectIsNull: IS_NULL({price: 85.23}),
48-
arrayIsNull: IS_NULL(["red", "blue", "yellow"]),
49-
populatedObjectPropertyIsNull: IS_NULL({quantity: 25, vendor: null}.quantity),
50-
invalidObjectPropertyIsNull: IS_NULL({quantity: 25, vendor: null}.size),
51-
nullObjectPropertyIsNull: IS_NULL({quantity: 25, vendor: null}.vendor)
52-
}
53-
```
54-
55-
```json
56-
[
57-
{
58-
"booleanIsNull": false,
59-
"numberIsNull": false,
60-
"stringIsNull": false,
61-
"nullIsNull": true,
62-
"objectIsNull": false,
63-
"arrayIsNull": false,
64-
"populatedObjectPropertyIsNull": false,
65-
"invalidObjectPropertyIsNull": false,
66-
"nullObjectPropertyIsNull": true
67-
}
68-
]
69-
```
41+
:::code language="sql" source="~/cosmos-db-nosql-query-samples/scripts/is-null/query.sql" highlight="2-10":::
42+
43+
:::code language="json" source="~/cosmos-db-nosql-query-samples/scripts/is-null/result.json":::
7044

7145
## Remarks
7246

73-
- This system function benefits from a [range index](../../index-policy.md#includeexclude-strategy).
47+
- This function benefits from a [range index](../../index-policy.md#includeexclude-strategy).
7448

7549
## Next steps
7650

0 commit comments

Comments
 (0)