Skip to content

Commit 730f091

Browse files
authored
[Cosmos] move system_key logic to query_iterable (Azure#22893)
* moving system_key overhead to container creation for queries to work * Update CHANGELOG.md * Update CHANGELOG.md * Update database.py * moved awaiting logic to query_iterable_async.py * Update CHANGELOG.md * Update database.py
1 parent 3c03c04 commit 730f091

File tree

3 files changed

+11
-13
lines changed

3 files changed

+11
-13
lines changed

sdk/cosmos/azure-cosmos/CHANGELOG.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,15 @@
1212
> for more details on consistency levels, or the README section on this change [here](https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/cosmos/azure-cosmos#note-on-client-consistency-levels).
1313
1414
#### Features Added
15-
- Added support for split-proof queries for the async client
15+
- Added support for split-proof queries for the async client.
1616

1717
### Bugs fixed
1818
- Default consistency level for the sync and async clients is no longer "Session" and will instead be set to the
19-
consistency level of the user's cosmos account setting on initialization if not passed during client initialization.
19+
consistency level of the user's cosmos account setting on initialization if not passed during client initialization.
2020
This change will impact client application in terms of RUs and latency. Users relying on default `Session` consistency will need to pass it explicitly if their account consistency is different than `Session`.
2121
Please see [Consistency Levels in Azure Cosmos DB](https://docs.microsoft.com/azure/cosmos-db/consistency-levels) for more details.
2222
- Fixed invalid request body being sent when passing in `serverScript` body parameter to replace operations for trigger, sproc and udf resources.
23+
- Moved `is_system_key` logic in async client.
2324
- Fixed TypeErrors not being thrown when passing in invalid connection retry policies to the client.
2425

2526
### 4.3.0b2 (2022-01-25)
@@ -28,15 +29,15 @@ This version and all future versions will require Python 3.6+. Python 2.7 is no
2829
We will also be removing support for Python 3.6 and will only support Python 3.7+ starting December 2022.
2930

3031
#### Features Added
31-
- Added support for split-proof queries for the sync client
32+
- Added support for split-proof queries for the sync client.
3233

3334
#### Other Changes
34-
- Added async user agent for async client
35+
- Added async user agent for async client.
3536

3637
### 4.3.0b1 (2021-12-14)
3738

3839
#### Features Added
39-
- Added language native async i/o client
40+
- Added language native async i/o client.
4041

4142
### 4.2.0 (2020-10-08)
4243

sdk/cosmos/azure-cosmos/azure/cosmos/aio/_query_iterable_async.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
"""Iterable query results in the Azure Cosmos database service.
2323
"""
24+
import asyncio
2425
from azure.core.async_paging import AsyncPageIterator
2526
from azure.cosmos._execution_context.aio import execution_dispatcher
2627

@@ -77,11 +78,6 @@ def __init__(
7778
)
7879
super(QueryIterable, self).__init__(self._fetch_next, self._unpack, continuation_token=continuation_token)
7980

80-
async def __aiter__(self):
81-
if 'partition_key' in self._options:
82-
self._options['partition_key'] = await self._options['partition_key']
83-
return self
84-
8581
async def _unpack(self, block):
8682
continuation = None
8783
if self._client.last_response_headers:
@@ -100,6 +96,9 @@ async def _fetch_next(self, *args): # pylint: disable=unused-argument
10096
:return: List of results.
10197
:rtype: list
10298
"""
99+
100+
if 'partitionKey' in self._options and asyncio.iscoroutine(self._options['partitionKey']):
101+
self._options['partitionKey'] = await self._options['partitionKey']
103102
block = await self._ex_context.fetch_next_block()
104103
if not block:
105104
raise StopAsyncIteration

sdk/cosmos/azure-cosmos/azure/cosmos/aio/database.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -275,9 +275,7 @@ async def create_container_if_not_exists(
275275
analytical_storage_ttl = kwargs.pop("analytical_storage_ttl", None)
276276
try:
277277
container_proxy = self.get_container_client(id)
278-
await container_proxy.read(
279-
**kwargs
280-
)
278+
await container_proxy.read(**kwargs)
281279
return container_proxy
282280
except CosmosResourceNotFoundError:
283281
return await self.create_container(

0 commit comments

Comments
 (0)