Skip to content
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

Computed properties Python Support #33626

Merged
merged 9 commits into from
Jan 9, 2024
Merged

Computed properties Python Support #33626

merged 9 commits into from
Jan 9, 2024

Conversation

bambriz
Copy link
Member

@bambriz bambriz commented Dec 20, 2023

Description

Adds support for computed properties.

Sample Usage:

 computed_properties = [{'name': "cp_str_len", 'query': "SELECT VALUE LENGTH(c.stringProperty) FROM c"}]
container = db.create_container("Container_id", partition_key= PartitionKey(path="\pk"), computed_properties=computed_properties)
queried_items = list(container.query_items(query='Select * from c Where c.cp_str_len = 9', partition_key="test")"

Also see Feature Doc

Computed properties cannot have aggregate functions.

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.

Adds the keyword for computed properties in container creation
Added keyword description for computed properties
This adds support for computed properties in the python SDK.
@bambriz
Copy link
Member Author

bambriz commented Dec 20, 2023

/azp run python - cosmos - ci

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@azure-sdk
Copy link
Collaborator

azure-sdk commented Dec 20, 2023

API change check

API changes are not detected in this pull request.

removed code used for local testing
@bambriz
Copy link
Member Author

bambriz commented Dec 20, 2023

/azp run python - cosmos - ci

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Updated changelog
@bambriz bambriz marked this pull request as ready for review December 20, 2023 21:51
@bambriz bambriz changed the title Comp prop Computed properties Python Support Dec 20, 2023
Copy link
Member

@simorenoh simorenoh left a comment

Choose a reason for hiding this comment

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

awesome stuff, thanks Bryan! let's make sure to update the changelog and it should be good to go 👍

pipeline complained about link in changelog being broken, updated the link.
Copy link
Member

@simorenoh simorenoh left a comment

Choose a reason for hiding this comment

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

let's shorten the information in the docs and we should be good, thanks!

sdk/cosmos/azure-cosmos/azure/cosmos/aio/_database.py Outdated Show resolved Hide resolved
Old docstrings descriptions were too long. Updated to better match the docstrings in java and provide a link to access further information about computed properties.
@bambriz
Copy link
Member Author

bambriz commented Jan 8, 2024

/azp run python - cosmos - ci

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@simorenoh simorenoh merged commit 4822e5c into Azure:main Jan 9, 2024
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants