Skip to content

Commit 3132ef8

Browse files
author
Jill Grant
authored
Merge pull request #245534 from seesharprun/cosmos-populate-nosql-2
Cosmos DB | Add NoSQL query functions #4
2 parents 7940a7c + 2f13d4a commit 3132ef8

File tree

10 files changed

+164
-403
lines changed

10 files changed

+164
-403
lines changed

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

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

@@ -38,55 +38,19 @@ Integer identifying an item within a physical partition.
3838

3939
This example illustrates using this function to extract and return the integer identifier relative to a physical partition.
4040

41-
```json
42-
[
43-
{
44-
"id": "63700",
45-
"name": "Joltage Kid's Vest"
46-
}
47-
]
48-
```
41+
:::code language="json" source="~/cosmos-db-nosql-query-samples/scripts/documentid/seed.novalidate.json" highlight="3":::
4942

50-
```sql
51-
SELECT
52-
p.id,
53-
p._rid,
54-
DOCUMENTID(p) AS documentId
55-
FROM
56-
product p
57-
```
43+
:::code language="sql" source="~/cosmos-db-nosql-query-samples/scripts/documentid/query.novalidate.sql" highlight="4":::
5844

59-
```json
60-
[
61-
{
62-
"id": "63700",
63-
"_rid": "36ZyAPW+uN8NAAAAAAAAAA==",
64-
"documentId": 13
65-
}
66-
]
67-
```
45+
:::code language="json" source="~/cosmos-db-nosql-query-samples/scripts/documentid/result.novalidate.json":::
6846

6947
This function can also be used as a filter.
7048

71-
```sql
72-
SELECT
73-
p.id,
74-
DOCUMENTID(p) AS documentId
75-
FROM
76-
product p
77-
WHERE
78-
DOCUMENTID(p) >= 5 AND
79-
DOCUMENTID(p) <= 15
80-
```
49+
:::code language="json" source="~/cosmos-db-nosql-query-samples/scripts/documentid-filter/seed.novalidate.json" highlight="3":::
8150

82-
```json
83-
[
84-
{
85-
"id": "63700",
86-
"documentId": 13
87-
}
88-
]
89-
```
51+
:::code language="sql" source="~/cosmos-db-nosql-query-samples/scripts/documentid-filter/query.novalidate.sql" highlight="3,7-8":::
52+
53+
:::code language="json" source="~/cosmos-db-nosql-query-samples/scripts/documentid-filter/result.novalidate.json":::
9054

9155
## Remarks
9256

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

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

@@ -21,15 +21,15 @@ Returns a boolean value indicating whether the first string expression ends with
2121
## Syntax
2222

2323
```sql
24-
ENDSWITH(<str_expr_1>, <str_expr_2> [, <bool_expr>])
24+
ENDSWITH(<string_expr_1>, <string_expr_2> [, <bool_expr>])
2525
```
2626

2727
## Arguments
2828

2929
| | Description |
3030
| --- | --- |
31-
| **`str_expr_1`** | A string expression. |
32-
| **`str_expr_2`** | A string expression to be compared to the end of `str_expr_1`. |
31+
| **`string_expr_1`** | A string expression. |
32+
| **`string_expr_2`** | A string expression to be compared to the end of `string_expr_1`. |
3333
| **`bool_expr`** *(Optional)* | Optional value for ignoring case. When set to `true`, `ENDSWITH` does a case-insensitive search. When unspecified, this default value is `false`. |
3434

3535
## Return types
@@ -40,25 +40,9 @@ Returns a boolean expression.
4040

4141
The following example checks if the string `abc` ends with `b` or `bC`.
4242

43-
```sql
44-
SELECT VALUE {
45-
endsWithWrongSuffix: ENDSWITH("abc", "b"),
46-
endsWithCorrectSuffix: ENDSWITH("abc", "bc"),
47-
endsWithSuffixWrongCase: ENDSWITH("abc", "bC"),
48-
endsWithSuffixCaseInsensitive: ENDSWITH("abc", "bC", true)
49-
}
50-
```
51-
52-
```json
53-
[
54-
{
55-
"endsWithWrongSuffix": false,
56-
"endsWithCorrectSuffix": true,
57-
"endsWithSuffixWrongCase": false,
58-
"endsWithSuffixCaseInsensitive": true
59-
}
60-
]
61-
```
43+
:::code language="sql" source="~/cosmos-db-nosql-query-samples/scripts/endswith/query.sql" highlight="2-5":::
44+
45+
:::code language="json" source="~/cosmos-db-nosql-query-samples/scripts/endswith/result.json":::
6246

6347
## Remarks
6448

Lines changed: 39 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,54 @@
11
---
2-
title: EXP in Azure Cosmos DB query language
3-
description: Learn about the Exponent (EXP) SQL system function in Azure Cosmos DB to return the exponential value of the specified numeric expression
4-
author: ginamr
2+
title: EXP
3+
titleSuffix: Azure Cosmos DB for NoSQL
4+
description: An Azure Cosmos DB for NoSQL system function that returns the exponential value 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: 09/13/2019
9-
ms.author: girobins
10-
ms.custom: query-reference, ignite-2022
10+
ms.topic: reference
11+
ms.date: 07/19/2023
12+
ms.custom: query-reference
1113
---
12-
# EXP (Azure Cosmos DB)
14+
15+
# EXP (NoSQL query)
16+
1317
[!INCLUDE[NoSQL](../../includes/appliesto-nosql.md)]
1418

15-
Returns the exponential value of the specified numeric expression.
16-
19+
Returns the exponential value of the specified numeric expression.
20+
1721
## Syntax
18-
22+
1923
```sql
20-
EXP (<numeric_expr>)
21-
```
22-
24+
EXP(<numeric_expr>)
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-
32-
## Remarks
33-
34-
The constant **e** (2.718281…), is the base of natural logarithms.
35-
36-
The exponent of a number is the constant **e** raised to the power of the number. For example, EXP(1.0) = e^1.0 = 2.71828182845905 and EXP(10) = e^10 = 22026.4657948067.
37-
38-
The exponential of the natural logarithm of a number is the number itself: EXP (LOG (n)) = n. And the natural logarithm of the exponential of a number is the number itself: LOG (EXP (n)) = n.
39-
34+
35+
Returns a numeric expression.
36+
4037
## Examples
41-
42-
The following example declares a variable and returns the exponential value of the specified variable (10).
43-
44-
```sql
45-
SELECT EXP(10) AS exp
46-
```
47-
48-
Here is the result set.
49-
50-
```json
51-
[{exp: 22026.465794806718}]
52-
```
53-
54-
The following example returns the exponential value of the natural logarithm of 20 and the natural logarithm of the exponential of 20. Because these functions are inverse functions of one another, the return value with rounding for floating point math in both cases is 20.
55-
56-
```sql
57-
SELECT EXP(LOG(20)) AS exp1, LOG(EXP(20)) AS exp2
58-
```
59-
60-
Here is the result set.
61-
62-
```json
63-
[{exp1: 19.999999999999996, exp2: 20}]
64-
```
38+
39+
The following example returns the exponential value for various numeric inputs.
40+
41+
:::code language="sql" source="~/cosmos-db-nosql-query-samples/scripts/exp/query.sql" highlight="2-4":::
42+
43+
:::code language="json" source="~/cosmos-db-nosql-query-samples/scripts/exp/result.json":::
44+
45+
## Remarks
46+
47+
- The constant `e` (`2.718281…`), is the base of natural logarithms.
48+
- The exponent of a number is the constant `e` raised to the power of the number. For example, `EXP(1.0) = e^1.0 = 2.71828182845905` and `EXP(10) = e^10 = 22026.4657948067`.
49+
- The exponential of the natural logarithm of a number is the number itself: `EXP (LOG (n)) = n`. And the natural logarithm of the exponential of a number is the number itself: `LOG (EXP (n)) = n`.
6550

6651
## Next steps
6752

6853
- [System functions Azure Cosmos DB](system-functions.yml)
69-
- [Introduction to Azure Cosmos DB](../../introduction.md)
54+
- [`LOG`](log.md)

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

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

@@ -38,26 +38,9 @@ Returns a numeric expression.
3838

3939
The following example shows positive numeric, negative, and zero values evaluated with this function.
4040

41-
```sql
42-
SELECT VALUE {
43-
floorPostiveNumber: FLOOR(62.6),
44-
floorNegativeNumber: FLOOR(-145.12),
45-
floorSmallNumber: FLOOR(0.2989),
46-
floorZero: FLOOR(0.0),
47-
floorNull: FLOOR(null)
48-
}
49-
```
41+
:::code language="sql" source="~/cosmos-db-nosql-query-samples/scripts/floor/query.sql" highlight="2-6":::
5042

51-
```json
52-
[
53-
{
54-
"floorPostiveNumber": 62,
55-
"floorNegativeNumber": -146,
56-
"floorSmallNumber": 0,
57-
"floorZero": 0
58-
}
59-
]
60-
```
43+
:::code language="json" source="~/cosmos-db-nosql-query-samples/scripts/floor/result.json":::
6144

6245
## Remarks
6346

Lines changed: 31 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,52 @@
11
---
2-
title: GetCurrentDateTime in Azure Cosmos DB query language
3-
description: Learn about SQL system function GetCurrentDateTime in Azure Cosmos DB.
4-
author: seesharprun
2+
title: GetCurrentDateTime
3+
titleSuffix: Azure Cosmos DB for NoSQL
4+
description: An Azure Cosmos DB for NoSQL system function that returns an ISO 8601 date and time 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: 02/03/2021
9-
ms.author: sidandrews
10-
ms.reviewer: jucocchi
11-
ms.custom: query-reference, ignite-2022
10+
ms.topic: reference
11+
ms.date: 07/19/2023
12+
ms.custom: query-reference
1213
---
13-
# GetCurrentDateTime (Azure Cosmos DB)
14+
15+
# GetCurrentDateTime (NoSQL query)
16+
1417
[!INCLUDE[NoSQL](../../includes/appliesto-nosql.md)]
1518

1619
Returns the current UTC (Coordinated Universal Time) date and time as an ISO 8601 string.
17-
20+
1821
## Syntax
19-
22+
2023
```sql
21-
GetCurrentDateTime ()
24+
GetCurrentDateTime()
2225
```
2326

2427
## Return types
25-
26-
Returns the current UTC date and time ISO 8601 string value in the format `YYYY-MM-DDThh:mm:ss.fffffffZ` where:
27-
28-
|Format|Description|
29-
|-|-|
30-
|YYYY|four-digit year|
31-
|MM|two-digit month (01 = January, etc.)|
32-
|DD|two-digit day of month (01 through 31)|
33-
|T|signifier for beginning of time elements|
34-
|hh|two-digit hour (00 through 23)|
35-
|mm|two-digit minutes (00 through 59)|
36-
|ss|two-digit seconds (00 through 59)|
37-
|.fffffff|seven-digit fractional seconds|
38-
|Z|UTC (Coordinated Universal Time) designator|
39-
40-
For more information on the ISO 8601 format, see [ISO_8601](https://en.wikipedia.org/wiki/ISO_8601)
4128

42-
## Remarks
43-
44-
GetCurrentDateTime() is a nondeterministic function. The result returned is UTC. Precision is 7 digits, with an accuracy of 100 nanoseconds.
29+
Returns the current UTC date and time string value in the **round-trip** (ISO 8601) format.
4530

4631
> [!NOTE]
47-
> This system function will not utilize the index. If you need to compare values to the current time, obtain the current time before query execution and use that constant string value in the `WHERE` clause.
32+
> For more information on the round-trip format, see [.NET round-trip format](/dotnet/standard/base-types/standard-date-and-time-format-strings#the-round-trip-o-o-format-specifier). For more information on the ISO 8601 format, see [ISO 8601](https://wikipedia.org/wiki/ISO_8601).
4833
4934
## Examples
50-
51-
The following example shows how to get the current UTC Date Time using the GetCurrentDateTime() built-in function.
52-
53-
```sql
54-
SELECT GetCurrentDateTime() AS currentUtcDateTime
55-
```
56-
57-
Here is an example result set.
58-
59-
```json
60-
[{
61-
"currentUtcDateTime": "2019-05-03T20:36:17.1234567Z"
62-
}]
63-
```
35+
36+
The following example shows how to get the current UTC date and time string.
37+
38+
:::code language="sql" source="~/cosmos-db-nosql-query-samples/scripts/getcurrentdatetime/query.novalidate.sql" highlight="2":::
39+
40+
:::code language="json" source="~/cosmos-db-nosql-query-samples/scripts/getcurrentdatetime/result.novalidate.json":::
41+
42+
## Remarks
43+
44+
- This function is nondeterministic.
45+
- The result returned is UTC (Coordinated Universal Time) with precision of seven digits and an accuracy of 100 nanoseconds.
46+
- This function doesn't use the index.
47+
- If you need to compare values to the current time, obtain the current time before query execution and use that constant string value in the `WHERE` clause.
6448

6549
## Next steps
6650

6751
- [System functions Azure Cosmos DB](system-functions.yml)
68-
- [Introduction to Azure Cosmos DB](../../introduction.md)
52+
- [`GetCurrentDateTimeStatic`](getcurrentdatetimestatic.md)

0 commit comments

Comments
 (0)