Repository navigation
[Cosmos] fix partition_key type in create container method - #34795
Hussein Awala (hussein-awala) wants to merge 1 commit into
Conversation
|
Thank you for your contribution Hussein Awala (@hussein-awala)! We will review the pull request and get back to you soon. |
|
@microsoft-github-policy-service agree |
|
Thanks so much for this Hussein Awala (@hussein-awala) - changes look good to me, but adding Simon Moreno (@simorenoh) and bambriz to confirm from the service team. |
|
hi Hussein Awala (@hussein-awala) - I'm not entirely positive on the mypy issue that is present for you folks at apache airflow, but these are not changes that we can do on our end. We have not allowed for the creation of non-partitioned containers for years now, and the current improvements we have made to our typing within the Cosmos SDK are relevant and up to date with the behavior we have for the client and for the underlying service. Since the beginning of the async client, this has been marked as a non-optional field for the relevant methods: And that is for good reason - like I mentioned, this is not behavior we have allowed for several years now and users should be seeing an error when attempting to use None for a partition key definition: As such, I'll be closing this PR. |
This seems incorrect, the method still accepts azure-sdk-for-python/sdk/cosmos/azure-cosmos/azure/cosmos/database.py Lines 224 to 225 in a7b794d azure-sdk-for-python/sdk/cosmos/azure-cosmos/azure/cosmos/aio/_database.py Lines 228 to 229 in a7b794d And from Cosmos documentation:
|
|
Hussein Awala (@hussein-awala) I see what you mean - while that may look like redundant code, we actually have it there on purpose to ensure we don't fill out the container definition with a None partition key. Reason for that being that the error message returned by the service is a lot more informative that way. Compare the one I sent before vs. this one: You also only included part of that page on documentation for migrating from non-partitioned collections (which are even marked as legacy in that same document) to newer partitioned ones. It is also mentioned there that the behavior is only available for versions <= 2.x. |




Description
This PR updates the type hint of
partition_keyparam in the methodscreate_containerandreplace_containerby making it optional, whereNoneis an accepted value to create nonpartitioned containers.related: apache/airflow#38196
related: #33341
All SDK Contribution checklist:
General Guidelines and Best Practices
Testing Guidelines