Skip to content

Add feed_range in query_items API #41722

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 21 commits into
base: main
Choose a base branch
from

Conversation

allenkim0129
Copy link
Contributor

@allenkim0129 allenkim0129 commented Jun 23, 2025

Description

Feed range is now available in the query_items API. Users can pass specific feed range to query items.

Like other SDKs, feed_range cannot be used with partition_key. If both are used, an error will be raised.

exmaple:

import json

for feed_range in container.read_feed_ranges():
    for queried_item in container.query_items(
        query='SELECT * FROM c',
        enable_cross_partition_query=True,
        feed_range=feed_range,
    ):
        print(json.dumps(queried_item, indent=True))

All SDK Contribution checklist:

  • The pull request does not introduce [breaking changes]
  • CHANGELOG is updated for new features, bug fixes or other significant changes.
  • I have read the contribution guidelines.

General Guidelines and Best Practices

  • Title of the pull request is clear and informative.
  • There are a small number of commits, each of which have an informative message. This means that previously merged commits do not appear in the history of the PR. For more information on cleaning up the commits in your PR, see this page.

Testing Guidelines

  • Pull request includes test coverage for the included changes.

Copy link

github-actions bot commented Jun 23, 2025

API Change Check

APIView identified API level changes in this PR and created the following API reviews

azure-cosmos

@allenkim0129
Copy link
Contributor Author

/azp run python - cosmos - tests

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@allenkim0129
Copy link
Contributor Author

/azp run python - cosmos - tests

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@allenkim0129
Copy link
Contributor Author

/azp run python - cosmos - tests

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@allenkim0129
Copy link
Contributor Author

/azp run python - cosmos - tests

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@allenkim0129 allenkim0129 marked this pull request as ready for review June 24, 2025 21:45
@Copilot Copilot AI review requested due to automatic review settings June 24, 2025 21:45
@allenkim0129 allenkim0129 requested a review from a team as a code owner June 24, 2025 21:45
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for the new feed_range parameter in the query_items API, bringing Python in line with other SDKs, and updates several internal utilities for argument handling and exclusive-parameter validation.

  • Introduced feed_range support in both sync and async query_items methods
  • Added add_args_to_kwargs and verify_exclusive_arguments helpers and corresponding unit tests
  • Updated samples, tests, partition‐key logic, and overload signatures to integrate feed_range

Reviewed Changes

Copilot reviewed 20 out of 20 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
samples/examples.py / examples_async.py Added code examples for feed_range queries (tags need fix)
azure/cosmos/container.py Wire in feed_range, drop legacy overloads, use new utils
azure/cosmos/_utils.py Added add_args_to_kwargs and verify_exclusive_arguments
tests/test_utils.py New unit tests for the helpers
tests/test_query_feed_range*.py End-to-end tests for sync/async feed-range queries
other partition_key and connection code Refactored _get_… APIs to get_…, new PartitionKeyKind/Version
Comments suppressed due to low confidence (4)

sdk/cosmos/azure-cosmos/samples/examples_async.py:275

  • The end marker here should match the start marker. Change [END query_items_param] to [END query_items_feed_range] for consistency.
        # [END query_items_param]

sdk/cosmos/azure-cosmos/samples/examples.py:152

  • This end tag should match the corresponding start tag [START query_items_feed_range]. Rename it to [END query_items_feed_range].
# [END query_items_param]

sdk/cosmos/azure-cosmos/azure/cosmos/container.py:592

  • The first overload definition doesn't include feed_range in its signature, which may confuse IDE users. You could add an overload that includes feed_range in the parameter list or adjust the existing overloads for consistency.
    def query_items(

sdk/cosmos/azure-cosmos/azure/cosmos/container.py:863

  • The code correctly prevents using feed_range and partition_key together, but there isn't an integration test for that error path. Consider adding a test that calls query_items with both parameters and asserts a ValueError.
        utils.verify_exclusive_arguments(["feed_range", "partition_key"], **kwargs)

@allenkim0129
Copy link
Contributor Author

/azp run python - cosmos - tests

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@allenkim0129
Copy link
Contributor Author

/azp run python - cosmos - tests

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@allenkim0129
Copy link
Contributor Author

/azp run python - cosmos - tests

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@allenkim0129
Copy link
Contributor Author

/azp run python - cosmos - tests

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

- Doc string updates
- Tests were updated to use existing helper methods
- Added tests with query_items with feed_range and partition_key
@allenkim0129
Copy link
Contributor Author

/azp run python - cosmos - tests

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@allenkim0129
Copy link
Contributor Author

/azp run python - cosmos - tests

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@allenkim0129
Copy link
Contributor Author

/azp run python - cosmos - tests

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

2 participants