Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
c811dd4
Add feed_range to query_items API
allenkim0129 Jun 11, 2025
40e61dd
Added overload methods for 'query_items' API
allenkim0129 Jun 18, 2025
53cf357
Added Tests
allenkim0129 Jun 19, 2025
609274f
Added feed_range to query_item for async
allenkim0129 Jun 19, 2025
9dadc7d
Added samples for query_items with feed_range
allenkim0129 Jun 23, 2025
2a89be8
Merge branch 'main' into users/allekim/addFeedRangeForQuery
allenkim0129 Jun 23, 2025
9958b70
Fix pylint error
allenkim0129 Jun 23, 2025
c64f832
Updated CHANGELOG.md
allenkim0129 Jun 23, 2025
de1446f
Fix test error
allenkim0129 Jun 23, 2025
fed65bf
Fix test error
allenkim0129 Jun 24, 2025
643b16f
Changed to run feed_range async tests on emulator only
allenkim0129 Jun 24, 2025
5940578
Fix tests
allenkim0129 Jun 25, 2025
a06526b
Fix tests
allenkim0129 Jun 25, 2025
973c4a8
Fix tests
allenkim0129 Jun 25, 2025
2a71b63
Fix tests with positional_args
allenkim0129 Jun 26, 2025
1b02d46
Addressing comments
allenkim0129 Jul 3, 2025
da8ac14
Fix pylint error
allenkim0129 Jul 7, 2025
db5b0c5
Changed to non-public APIs for internal classes/methods
allenkim0129 Jul 11, 2025
ba07870
Changed to non-public APIs for internal classes/methods
allenkim0129 Jul 11, 2025
28f1518
Changed to non-public APIs for internal classes/methods
allenkim0129 Jul 11, 2025
4a4a7bc
Pylint error
allenkim0129 Jul 11, 2025
b289b66
Pylint error
allenkim0129 Jul 14, 2025
2b1aae6
Address comments
allenkim0129 Jul 15, 2025
f61a987
Merge branch 'main' into users/allekim/addFeedRangeForQuery
allenkim0129 Jul 16, 2025
fd8ceb7
Add newline at the end _utils.py
allenkim0129 Jul 16, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Changed to non-public APIs for internal classes/methods
  • Loading branch information
allenkim0129 committed Jul 11, 2025
commit db5b0c5f8dd4d8755831fe7b85b50161ecd8d080
Original file line number Diff line number Diff line change
Expand Up @@ -3166,7 +3166,7 @@ def __GetBodiesFromQueryResult(result: Dict[str, Any]) -> List[Dict[str, Any]]:
elif "prefix_partition_key_object" in kwargs and "prefix_partition_key_value" in kwargs:
prefix_partition_key_obj = kwargs.pop("prefix_partition_key_object")
prefix_partition_key_value: SequentialPartitionKeyType = kwargs.pop("prefix_partition_key_value")
feed_range_epk = prefix_partition_key_obj.get_epk_range_for_prefix_partition_key(prefix_partition_key_value)
feed_range_epk = prefix_partition_key_obj._get_epk_range_for_prefix_partition_key(prefix_partition_key_value)

# If feed_range_epk exist, query with the range
if feed_range_epk is not None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def create_pk_range_wrapper(self, request: RequestObject) -> Optional[PartitionK
if HttpHeaders.PartitionKey in request.headers:
partition_key_value = request.headers[HttpHeaders.PartitionKey]
# get the partition key range for the given partition key
epk_range = [partition_key.get_epk_range_for_partition_key(partition_key_value)] # pylint: disable=protected-access
epk_range = [partition_key._get_epk_range_for_partition_key(partition_key_value)] # pylint: disable=protected-access
partition_ranges = (self.client._routing_map_provider # pylint: disable=protected-access
.get_overlapping_ranges(container_link, epk_range))
partition_range = Range.PartitionKeyRangeToRange(partition_ranges[0])
Expand Down
2 changes: 1 addition & 1 deletion sdk/cosmos/azure-cosmos/azure/cosmos/aio/_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ async def _get_epk_range_for_partition_key(
partition_key_definition = container_properties["partitionKey"]
partition_key = get_partition_key_from_definition(partition_key_definition)

return partition_key.get_epk_range_for_partition_key(partition_key_value)
return partition_key._get_epk_range_for_partition_key(partition_key_value)

@distributed_trace_async
async def read(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
SequentialPartitionKeyType,
_return_undefined_or_empty_partition_key,
NonePartitionKeyValue, _Empty,
build_partition_key_from_properties,
_build_partition_key_from_properties,
)
from ._auth_policy_async import AsyncCosmosBearerTokenCredentialPolicy
from .._cosmos_http_logging_policy import CosmosHttpLoggingPolicy
Expand Down Expand Up @@ -2961,11 +2961,11 @@ def __GetBodiesFromQueryResult(result: Dict[str, Any]) -> List[Dict[str, Any]]:
elif options.get("partitionKey") is not None and container_property is not None:
# check if query has prefix partition key
partition_key_value = options["partitionKey"]
partition_key_obj = build_partition_key_from_properties(container_property)
partition_key_obj = _build_partition_key_from_properties(container_property)
if partition_key_obj.is_prefix_partition_key(partition_key_value):
req_headers.pop(http_constants.HttpHeaders.PartitionKey, None)
partition_key_value = cast(SequentialPartitionKeyType, partition_key_value)
feed_range_epk = partition_key_obj.get_epk_range_for_prefix_partition_key(partition_key_value)
feed_range_epk = partition_key_obj._get_epk_range_for_prefix_partition_key(partition_key_value)

if feed_range_epk is not None:
over_lapping_ranges = await self._routing_map_provider.get_overlapping_ranges(id_, [feed_range_epk],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ async def create_pk_range_wrapper(self, request: RequestObject) -> Optional[Part
if HttpHeaders.PartitionKey in request.headers:
partition_key_value = request.headers[HttpHeaders.PartitionKey]
# get the partition key range for the given partition key
epk_range = [partition_key.get_epk_range_for_partition_key(partition_key_value)]
epk_range = [partition_key._get_epk_range_for_partition_key(partition_key_value)]
partition_ranges = await (self.client._routing_map_provider
.get_overlapping_ranges(container_link, epk_range))
partition_range = Range.PartitionKeyRangeToRange(partition_ranges[0])
Expand Down
8 changes: 4 additions & 4 deletions sdk/cosmos/azure-cosmos/azure/cosmos/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
PartitionKey,
PartitionKeyType,
SequentialPartitionKeyType,
build_partition_key_from_properties,
_build_partition_key_from_properties,
_return_undefined_or_empty_partition_key,
)
from .scripts import ScriptsProxy
Expand All @@ -65,8 +65,8 @@
def get_epk_range_for_partition_key(
container_properties: Dict[str, Any],
partition_key_value: PartitionKeyType) -> Range:
partition_key_obj: PartitionKey = build_partition_key_from_properties(container_properties)
return partition_key_obj.get_epk_range_for_partition_key(partition_key_value)
partition_key_obj: PartitionKey = _build_partition_key_from_properties(container_properties)
return partition_key_obj._get_epk_range_for_partition_key(partition_key_value)

class ContainerProxy: # pylint: disable=too-many-public-methods
"""An interface to interact with a specific DB Container.
Expand Down Expand Up @@ -863,7 +863,7 @@ def query_items( # pylint:disable=docstring-missing-param
utils.verify_exclusive_arguments(["feed_range", "partition_key"], **kwargs)
if "feed_range" not in kwargs and "partition_key" in kwargs:
partition_key_value = self._set_partition_key(kwargs.pop("partition_key"))
partition_key_obj = build_partition_key_from_properties(container_properties)
partition_key_obj = _build_partition_key_from_properties(container_properties)
if partition_key_obj.is_prefix_partition_key(partition_key_value):
kwargs["prefix_partition_key_object"] = partition_key_obj
kwargs["prefix_partition_key_value"] = cast(SequentialPartitionKeyType, partition_key_value)
Expand Down
12 changes: 6 additions & 6 deletions sdk/cosmos/azure-cosmos/azure/cosmos/partition_key.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ def version(self) -> int:
def version(self, value: int) -> None:
self["version"] = value

def get_epk_range_for_prefix_partition_key(
def _get_epk_range_for_prefix_partition_key(
self,
pk_value: SequentialPartitionKeyType
) -> _Range:
Expand All @@ -210,12 +210,12 @@ def get_epk_range_for_prefix_partition_key(
max_epk = str(min_epk) + "FF"
return _Range(min_epk, max_epk, True, False)

def get_epk_range_for_partition_key(
def _get_epk_range_for_partition_key(
self,
pk_value: PartitionKeyType
) -> _Range:
if self.is_prefix_partition_key(pk_value):
return self.get_epk_range_for_prefix_partition_key(
return self._get_epk_range_for_prefix_partition_key(
cast(SequentialPartitionKeyType, pk_value))

# else return point range
Expand Down Expand Up @@ -260,7 +260,7 @@ def _get_effective_partition_key_for_hash_partitioning(
return _to_hex_encoded_binary_string_v1(partition_key_components)

@staticmethod
def get_hashed_partition_key_string(
def _get_hashed_partition_key_string(
pk_value: SequentialPartitionKeyType,
kind: str,
version: int = PartitionKeyVersion.V2,
Expand All @@ -284,7 +284,7 @@ def _get_effective_partition_key_string(
if isinstance(self, _Infinity):
return _MaximumExclusiveEffectivePartitionKey

return PartitionKey.get_hashed_partition_key_string(pk_value=pk_value, kind=self.kind, version=self.version)
return PartitionKey._get_hashed_partition_key_string(pk_value=pk_value, kind=self.kind, version=self.version)

@staticmethod
def _write_for_hashing(
Expand Down Expand Up @@ -531,6 +531,6 @@ def get_partition_key_from_definition(
version: int = partition_key_definition.get("version", 1) # Default to version 1 if not provided
return PartitionKey(path=path, kind=kind, version=version)

def build_partition_key_from_properties(container_properties: Dict[str, Any]) -> PartitionKey:
def _build_partition_key_from_properties(container_properties: Dict[str, Any]) -> PartitionKey:
partition_key_definition = container_properties["partitionKey"]
return get_partition_key_from_definition(partition_key_definition)
Loading