-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
[Bug] Multiple partition key on cosmos db is not supported/has a bug in python cosmos sdk #30670
Comments
Thank you for the feedback @kaushikc3 . We will investigate and get back to you asap. |
Thank you for your feedback. This has been routed to the support team for assistance. |
Hi @kaushikc3, thank you for using our SDK. Were you trying to make use of hierarchical partition keys (https://learn.microsoft.com/azure/cosmos-db/hierarchical-partition-keys?tabs=net-v3%2Cbicep)? Just wondering what you were trying to do here so we can understand on our end. Do you have samples of this working on any of the other SDKs? |
Yes. We were trying to use hierarchical partition keys. But, python cosmos sdk seems to be constantly failing while dealing with a container configured with hierarchical partition keys. |
Sorry, to answer your question. Yes, we have the nodejs code working just fine with the hierarchical partition keys. But, we are blocked with python sdk not working. .Net, Java, Nodejs - all seem to be doing fine. We have one particular piece where NodeJS and Python both work on cosmos db documents. |
@kaushikc3 I see - yeah that is by design, our Python SDK does not yet support hierarchical partitioning. We are currently working on those changes, and they should be out by July. We'll keep you posted on this as the feature is developed/ released. |
Thank you @simorenoh for the quick answer. Will look forward to the July python sdk release. Thank you for clarifying. |
@simorenoh let's also update https://feedback.azure.com/d365community/idea/286ff8dc-dbfa-ed11-a81c-000d3a0d3715 when it's out. Thanks! |
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @pjohari-ms @simorenoh @gahl-levy @bambriz. |
@kaushikc3 the pr for subpartitioning is in review, should be available by end of July. PR 31121 |
I am also facing the same issue, but meanwhile is there any alternative or workaround for this? |
@kaushikc3 @aksjadha-amdocs PR to support subpartitioning (Multiple partition keys) has been merged see #31121 |
Hi @kaushikc3. Thank you for opening this issue and giving us the opportunity to assist. We believe that this has been addressed. If you feel that further discussion is needed, please add a comment with the text "/unresolve" to remove the "issue-addressed" label and continue the conversation. |
Hello @kaushikc3 @aksjadha-amdocs I am happy to announce that Sub partitioning has been released on Version 4.5.2b1. Please note that MultiHash Partition keys in the python SDK are managed as a list. |
We were trying to use cosmos db with multiple partition keys and the python code kept failing with an error "ValueError: Unsupported paths count.".
We did a big of analysis on this and found out the root cause of the problem. It seems to be coming in from the following piece of code under azure / cosmos / _base.py.
Parses the paths into a list of token each representing a property
def ParsePaths(paths):
if len(paths) != 1:
raise ValueError("Unsupported paths count.")
Stack Trace below:
File "C:\Users\kramac3\Source\Repos\misc\python-comp-key-trial\quickTry.py", line 16, in create_pad
cases_container.create_item(pad_doc.dict)
File "C:\Users\kramac3\AppData\Roaming\Python\Python39\site-packages\azure\core\tracing\decorator.py", line 78, in wrapper_use_tracer
return func(*args, **kwargs)
File "C:\Users\kramac3\AppData\Roaming\Python\Python39\site-packages\azure\cosmos\container.py", line 566, in create_item
result = self.client_connection.CreateItem(
File "C:\Users\kramac3\AppData\Roaming\Python\Python39\site-packages\azure\cosmos_cosmos_client_connection.py", line 1125, in CreateItem
options = self._AddPartitionKey(database_or_container_link, document, options)
File "C:\Users\kramac3\AppData\Roaming\Python\Python39\site-packages\azure\cosmos_cosmos_client_connection.py", line 2645, in _AddPartitionKey
partitionKeyValue = self._ExtractPartitionKey(partitionKeyDefinition, document)
File "C:\Users\kramac3\AppData\Roaming\Python\Python39\site-packages\azure\cosmos_cosmos_client_connection.py", line 2654, in _ExtractPartitionKey
partition_key_parts = base.ParsePaths(partitionKeyDefinition.get("paths"))
File "C:\Users\kramac3\AppData\Roaming\Python\Python39\site-packages\azure\cosmos_base.py", line 607, in ParsePaths
raise ValueError("Unsupported paths count.")
This function needs to be changed to support extraction of multiple partition keys.
The text was updated successfully, but these errors were encountered: