You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/cosmos-db/nosql/query/computed-properties.md
+15-15Lines changed: 15 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -59,21 +59,21 @@ The constraints on computed property names are:
59
59
60
60
### Query constraints
61
61
62
-
Queries in the computed property definition must be valid syntactically and semantically, otherwise the create or update operation fails. Queries should evaluate to a deterministic value for all items in a container. Queries may evaluate to undefined or null for some items, and computed properties with undefined or null values behave the same as persisted properties with undefined or null values when used in queries.
62
+
Queries in the computed property definition must be valid syntactically and semantically, otherwise the create or update operation fails. Queries should evaluate to a deterministic value for all items in a container. Queries might evaluate to undefined or null for some items, and computed properties with undefined or null values behave the same as persisted properties with undefined or null values when used in queries.
63
63
64
64
The limitations on computed property query definitions are:
65
65
66
66
- Queries must specify a FROM clause that represents the root item reference. Examples of supported FROM clauses are: `FROM c`, `FROM root c`, and `FROM MyContainer c`.
67
67
- Queries must use a VALUE clause in the projection.
68
68
- Queries can't include a JOIN.
69
-
- Queries can't use non-deterministic Scalar expressions. Examples of non-deterministic scalar expressions are: GetCurrentDateTime, GetCurrentTimeStamp, GetCurrentTicks, and RAND.
69
+
- Queries can't use nondeterministic Scalar expressions. Examples of nondeterministic scalar expressions are: GetCurrentDateTime, GetCurrentTimeStamp, GetCurrentTicks, and RAND.
70
70
- Queries can't use any of the following clauses: WHERE, GROUP BY, ORDER BY, TOP, DISTINCT, OFFSET LIMIT, EXISTS, ALL, LAST, FIRST, and NONE.
71
71
- Queries can't include a scalar subquery.
72
72
- Aggregate functions, spatial functions, nondeterministic functions, and user defined functions (UDFs) aren't supported.
73
73
74
74
## Create computed properties
75
75
76
-
After the computed properties are created, you can execute queries that reference the properties by using any method, including all SDKs and Azure Data Explorer in the Azure portal.
76
+
After the computed properties are created, you can execute queries that reference the properties by using any method, including all software development kits (SDKs) and Azure Data Explorer in the Azure portal.
You can define multiple computed properties in a list and then add them to the container properties. Python SDK currently doesn't support computed properties on existing containers.
145
+
You can define multiple computed properties in a list and then add them to the container properties. Python SDK currently doesn't support computed properties on existing containers.
146
146
147
147
```python
148
148
computed_properties = [{'name': "cp_lower", 'query': "SELECT VALUE LOWER(c.db_group) FROM c"},
Computed properties can be used like any other property in queries. For example, you can use the computed property `cp_lower` in a query like this:
156
157
157
158
```python
158
159
queried_items =list(
159
160
container_with_computed_props.query_items(query='Select * from c Where c.cp_power = 25', partition_key="test"))
160
161
```
161
162
162
-
163
163
---
164
164
165
165
Here's an example of how to update computed properties on an existing container:
@@ -218,7 +218,8 @@ console.log("Container definition is undefined.");
218
218
```
219
219
220
220
### [Python](#tab/python)
221
-
Updating computed properties on an existing container is not supported in Python SDK. You can only define computed properties when creating a new container. This is a work in progress currently.
221
+
222
+
Updating computed properties on an existing container isn't supported in Python SDK. You can only define computed properties when creating a new container.
222
223
223
224
---
224
225
@@ -231,9 +232,9 @@ You can use the Data Explorer to create a computed property for a container.
231
232
232
233
1. Open your existing container in the Data Explorer.
233
234
234
-
1. Navigate to the **Settings** section for you container. Then, navigate to the **Computed Properties*sub-section.
235
+
1. Navigate to the **Settings** section for your container. Then, navigate to the **Computed Properties*subsection.
235
236
236
-
1. Edit the computed properties definition JSON for your container. In this example, this JSON is used to define a computed property to split the `SKU` string for a retail product using the `-`delimeter.
237
+
1. Edit the computed properties definition JSON for your container. In this example, this JSON is used to define a computed property to split the `SKU` string for a retail product using the `-`delimiter.
237
238
238
239
```json
239
240
[
@@ -382,14 +383,14 @@ ORDER BY
382
383
383
384
## Index computed properties
384
385
385
-
Computed properties aren't indexed by default and aren't covered by wildcard paths in the [indexing policy](../../index-policy.md). You can add single or composite indexes on computed properties in the indexing policy the same way you would add indexes on persisted properties. We recommend that you add relevant indexes to all computed properties. We recommend these indexes because they're beneficial in increasing performance and reducing RUs when they're indexed. When computed properties are indexed, actual values are evaluated during item write operations to generate and persist index terms.
386
+
Computed properties aren't indexed by default and aren't covered by wildcard paths in the [indexing policy](../../index-policy.md). You can add single or composite indexes on computed properties in the indexing policy the same way you would add indexes on persisted properties. We recommend that you add relevant indexes to all computed properties. We recommend these indexes because they're beneficial in increasing performance and reducing request units (RUs). When computed properties are indexed, actual values are evaluated during item write operations to generate and persist index terms.
386
387
387
388
There are a few considerations for indexing computed properties, including:
388
389
389
-
- Computed properties can be specified in included paths, excluded paths, and composite index paths.
390
-
- Computed properties can't have a spatial index defined on them.
391
-
- Wildcard paths under the computed property path work like they do for regular properties.
392
-
-If you're removing a computed property that has been indexed, all indexes on that property must also be dropped.
390
+
- Computed properties can be specified in included paths, excluded paths, and composite index paths
391
+
- Computed properties can't have a spatial index defined on them
392
+
- Wildcard paths under the computed property path work like they do for regular properties
393
+
-Related indexes on a removed and indexedproperty must also be dropped
393
394
394
395
> [!NOTE]
395
396
> All computed properties are defined at the top level of the item. The path is always `/<computed property name>`.
@@ -402,7 +403,6 @@ There are a few considerations for indexing computed properties, including:
402
403
>
403
404
> If you want to delete a computed property, you'll first need to remove it from the index policy.
404
405
405
-
406
406
### Add a single index for computed properties
407
407
408
408
To add a single index for a computed property named `cp_myComputedProperty`:
@@ -460,7 +460,7 @@ To add a composite index on two properties in which, one is computed as `cp_myCo
460
460
461
461
## Understand request unit consumption
462
462
463
-
Adding computed properties to a container doesn't consume RUs. Write operations on containers that have computed properties defined might have a slight RU increase. If a computed property is indexed, RUs on write operations increase to reflect the costs for indexing and evaluation of the computed property.
463
+
Adding computed properties to a container doesn't consume RUs. Write operations on containers that have computed properties defined might have a slight RU increase. If a computed property is indexed, RUs on write operations increase to reflect the costs for indexing and evaluation of the computed property.
0 commit comments