From 9031f9d5b4617daab09d0893c4b9ca781edeefe0 Mon Sep 17 00:00:00 2001 From: bambriz Date: Thu, 8 Jun 2023 10:12:15 -0700 Subject: [PATCH] Revert "Implement continuation token size limit (#30600)" This reverts commit cc8111003dc315c532a9a926a59fe4aff1c0c46f. --- .gitignore | 2 +- sdk/cosmos/azure-cosmos/CHANGELOG.md | 1 - sdk/cosmos/azure-cosmos/azure/cosmos/_base.py | 3 --- .../azure/cosmos/aio/_container.py | 7 ------- .../azure-cosmos/azure/cosmos/container.py | 6 ------ .../azure/cosmos/http_constants.py | 1 - .../samples/document_management.py | 18 ------------------ .../samples/document_management_async.py | 18 ------------------ sdk/cosmos/azure-cosmos/test/test_query.py | 19 ------------------- 9 files changed, 1 insertion(+), 74 deletions(-) diff --git a/.gitignore b/.gitignore index e1a96e22c61b..797ae4ea05e6 100644 --- a/.gitignore +++ b/.gitignore @@ -148,4 +148,4 @@ sdk/cosmos/azure-cosmos/test/test_config.py *_python.json # temporary folder to refresh SDK with cadl -TempTypeSpecFiles/ +TempTypeSpecFiles/ \ No newline at end of file diff --git a/sdk/cosmos/azure-cosmos/CHANGELOG.md b/sdk/cosmos/azure-cosmos/CHANGELOG.md index 43bb1f046ce6..8a5296ca920c 100644 --- a/sdk/cosmos/azure-cosmos/CHANGELOG.md +++ b/sdk/cosmos/azure-cosmos/CHANGELOG.md @@ -14,7 +14,6 @@ #### Features Added * Added conditional patching for Patch operations. See [PR 30455](https://github.com/Azure/azure-sdk-for-python/pull/30455). -* Added **provisional** ability to limit Continuation Token size when querying for items. See [PR 30600](https://github.com/Azure/azure-sdk-for-python/pull/30600) #### Bugs Fixed * Fixed bug with non english locales causing an error with the RFC 1123 Date Format. See [PR 30125](https://github.com/Azure/azure-sdk-for-python/pull/30125). diff --git a/sdk/cosmos/azure-cosmos/azure/cosmos/_base.py b/sdk/cosmos/azure-cosmos/azure/cosmos/_base.py index 62a2ccfa4b3f..fff801e85087 100644 --- a/sdk/cosmos/azure-cosmos/azure/cosmos/_base.py +++ b/sdk/cosmos/azure-cosmos/azure/cosmos/_base.py @@ -223,9 +223,6 @@ def GetHeaders( # pylint: disable=too-many-statements,too-many-branches if options.get("populateQueryMetrics"): headers[http_constants.HttpHeaders.PopulateQueryMetrics] = options["populateQueryMetrics"] - if options.get("responseContinuationTokenLimitInKb"): - headers[http_constants.HttpHeaders.ResponseContinuationTokenLimitInKb] = options["responseContinuationTokenLimitInKb"] # pylint: disable=line-too-long - if cosmos_client_connection.master_key: #formatedate guarantees RFC 1123 date format regardless of current locale headers[http_constants.HttpHeaders.XDate] = formatdate(timeval=None, localtime=False, usegmt=True) diff --git a/sdk/cosmos/azure-cosmos/azure/cosmos/aio/_container.py b/sdk/cosmos/azure-cosmos/azure/cosmos/aio/_container.py index ea0946f616af..1bd5c8e24310 100644 --- a/sdk/cosmos/azure-cosmos/azure/cosmos/aio/_container.py +++ b/sdk/cosmos/azure-cosmos/azure/cosmos/aio/_container.py @@ -320,9 +320,6 @@ def query_items( :keyword dict[str, str] initial_headers: Initial headers to be sent as part of the request. :keyword response_hook: A callable invoked with the response metadata. :paramtype response_hook: Callable[[Dict[str, str], AsyncItemPaged[Dict[str, Any]]], None] - :keyword int response_continuation_token_limit_in_kb: **provisional keyword** The size limit in kb of the - response continuation token in the query response. Valid values are positive integers. - A value of 0 is the same as not passing a value (default no limit). :keyword int max_integrated_cache_staleness_in_ms: The max cache staleness for the integrated cache in milliseconds. For accounts configured to use the integrated cache, using Session or Eventual consistency, responses are guaranteed to be no staler than this value. @@ -369,13 +366,9 @@ def query_items( feed_options["maxIntegratedCacheStaleness"] = max_integrated_cache_staleness_in_ms correlated_activity_id = GenerateGuidId() feed_options["correlatedActivityId"] = correlated_activity_id - response_continuation_token_limit_in_kb = kwargs.pop("response_continuation_token_limit_in_kb", None) - if response_continuation_token_limit_in_kb is not None: - feed_options["responseContinuationTokenLimitInKb"] = response_continuation_token_limit_in_kb if hasattr(response_hook, "clear"): response_hook.clear() - parameters = kwargs.pop('parameters', None) items = self.client_connection.QueryItems( database_or_container_link=self.container_link, diff --git a/sdk/cosmos/azure-cosmos/azure/cosmos/container.py b/sdk/cosmos/azure-cosmos/azure/cosmos/container.py index 60e979fd4035..4d5a14d12cc8 100644 --- a/sdk/cosmos/azure-cosmos/azure/cosmos/container.py +++ b/sdk/cosmos/azure-cosmos/azure/cosmos/container.py @@ -354,9 +354,6 @@ def query_items( :keyword str session_token: Token for use with Session consistency. :keyword dict[str,str] initial_headers: Initial headers to be sent as part of the request. :keyword Callable response_hook: A callable invoked with the response metadata. - :keyword int response_continuation_token_limit_in_kb: **provisional keyword** The size limit in kb of the - response continuation token in the query response. Valid values are positive integers. - A value of 0 is the same as not passing a value (default no limit). :keyword int max_integrated_cache_staleness_in_ms: The max cache staleness for the integrated cache in milliseconds. For accounts configured to use the integrated cache, using Session or Eventual consistency, responses are guaranteed to be no staler than this value. @@ -399,9 +396,6 @@ def query_items( feed_options["maxIntegratedCacheStaleness"] = max_integrated_cache_staleness_in_ms correlated_activity_id = GenerateGuidId() feed_options["correlatedActivityId"] = correlated_activity_id - response_continuation_token_limit_in_kb = kwargs.pop("response_continuation_token_limit_in_kb", None) - if response_continuation_token_limit_in_kb is not None: - feed_options["responseContinuationTokenLimitInKb"] = response_continuation_token_limit_in_kb if hasattr(response_hook, "clear"): response_hook.clear() diff --git a/sdk/cosmos/azure-cosmos/azure/cosmos/http_constants.py b/sdk/cosmos/azure-cosmos/azure/cosmos/http_constants.py index e9bf9c1b8de1..c1518edbde42 100644 --- a/sdk/cosmos/azure-cosmos/azure/cosmos/http_constants.py +++ b/sdk/cosmos/azure-cosmos/azure/cosmos/http_constants.py @@ -99,7 +99,6 @@ class HttpHeaders(object): # Our custom DocDB headers Continuation = "x-ms-continuation" PageSize = "x-ms-max-item-count" - ResponseContinuationTokenLimitInKb = "x-ms-documentdb-responsecontinuationtokenlimitinkb" # cspell:disable-line # Request sender generated. Simply echoed by backend. ActivityId = "x-ms-activity-id" diff --git a/sdk/cosmos/azure-cosmos/samples/document_management.py b/sdk/cosmos/azure-cosmos/samples/document_management.py index 3c64c4b605f3..41d68f7ec2ec 100644 --- a/sdk/cosmos/azure-cosmos/samples/document_management.py +++ b/sdk/cosmos/azure-cosmos/samples/document_management.py @@ -191,23 +191,6 @@ def delete_all_items_by_partition_key(db, partitionkey): for doc in item_list: print('Item Id: {0}; Partition Key: {1}'.format(doc.get('id'), doc.get("company"))) - -def query_items_with_continuation_token_size_limit(container, doc_id): - print('\n1.11 Query Items With Continuation Token Size Limit.\n') - - size_limit_in_kb = 8 - sales_order = get_sales_order(doc_id) - container.create_item(body=sales_order) - - # set response_continuation_token_limit_in_kb to 8 to limit size to 8KB - items = list(container.query_items( - query="SELECT * FROM r", - partition_key=doc_id, - response_continuation_token_limit_in_kb=size_limit_in_kb - )) - - print('Continuation Token size has been limited to {}KB.'.format(size_limit_in_kb)) - def get_sales_order(item_id): order1 = {'id' : item_id, 'account_number' : 'Account1', @@ -276,7 +259,6 @@ def run_sample(): patch_item(container, 'SalesOrder1') delete_item(container, 'SalesOrder1') delete_all_items_by_partition_key(db, "CompanyA") - query_items_with_continuation_token_size_limit(container, 'SalesOrder1') # cleanup database after sample try: diff --git a/sdk/cosmos/azure-cosmos/samples/document_management_async.py b/sdk/cosmos/azure-cosmos/samples/document_management_async.py index e14b43d862d8..5383937b844a 100644 --- a/sdk/cosmos/azure-cosmos/samples/document_management_async.py +++ b/sdk/cosmos/azure-cosmos/samples/document_management_async.py @@ -208,23 +208,6 @@ async def delete_all_items_by_partition_key(db, partitionkey): for doc in item_list: print('Item Id: {0}; Partition Key: {1}'.format(doc.get('id'), doc.get("company"))) - -async def query_items_with_continuation_token_size_limit(container, doc_id): - print('\n1.11 Query Items With Continuation Token Size Limit.\n') - - size_limit_in_kb = 8 - sales_order = get_sales_order(doc_id) - await container.create_item(body=sales_order) - - # set response_continuation_token_limit_in_kb to 8 to limit size to 8KB - items = container.query_items( - query="SELECT * FROM r", - partition_key=doc_id, - response_continuation_token_limit_in_kb=size_limit_in_kb - ) - - print('Continuation Token size has been limited to {}KB.'.format(size_limit_in_kb)) - def get_sales_order(item_id): order1 = {'id' : item_id, 'account_number' : 'Account1', @@ -295,7 +278,6 @@ async def run_sample(): await patch_item(container, 'SalesOrder1') await delete_item(container, 'SalesOrder1') await delete_all_items_by_partition_key(db, "CompanyA") - await query_items_with_continuation_token_size_limit(container, 'SalesOrder1') # cleanup database after sample try: diff --git a/sdk/cosmos/azure-cosmos/test/test_query.py b/sdk/cosmos/azure-cosmos/test/test_query.py index 3897fe178027..941993c0ca3f 100644 --- a/sdk/cosmos/azure-cosmos/test/test_query.py +++ b/sdk/cosmos/azure-cosmos/test/test_query.py @@ -10,8 +10,6 @@ import pytest import collections import test_config -from unittest.mock import MagicMock -from azure.cosmos import http_constants pytestmark = pytest.mark.cosmosEmulator @@ -830,23 +828,6 @@ def test_value_max_query(self): self.assertListEqual(list(query_results), [None]) - def side_effect_continuation_token_size_limit(self, *args, **kwargs): - # Extract request headers from args - self.assertTrue(args[2][http_constants.HttpHeaders.ResponseContinuationTokenLimitInKb] is 8) - raise StopIteration - - def test_continuation_token_size_limit_query(self): - container = self.created_db.create_container_if_not_exists( - self.config.TEST_COLLECTION_MULTI_PARTITION_WITH_CUSTOM_PK_ID, PartitionKey(path="/pk")) - cosmos_client_connection = container.client_connection - cosmos_client_connection._CosmosClientConnection__Get = MagicMock( - side_effect=self.side_effect_continuation_token_size_limit) - try: - query = "Select * from c" - container.query_items(query, response_continuation_token_limit_in_kb=8) - except StopIteration: - pass - def _MockNextFunction(self): if self.count < len(self.payloads): item, result = self.get_mock_result(self.payloads, self.count)