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

[Bug] Multiple partition key on cosmos db is not supported/has a bug in python cosmos sdk #30670

Closed
kaushikc3 opened this issue Jun 7, 2023 · 14 comments
Assignees
Labels
Client This issue points to a problem in the data-plane of the library. Cosmos customer-reported Issues that are reported by GitHub users external to the Azure organization. issue-addressed Workflow: The Azure SDK team believes it to be addressed and ready to close. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Service Attention Workflow: This issue is responsible by Azure service team.

Comments

@kaushikc3
Copy link

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.

@github-actions github-actions bot added customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that labels Jun 7, 2023
@kaushikc3 kaushikc3 changed the title Multiple parition key on cosmos db is not supported/has a bug [Bug] Multiple parition key on cosmos db is not supported/has a bug Jun 7, 2023
@kaushikc3 kaushikc3 changed the title [Bug] Multiple parition key on cosmos db is not supported/has a bug [Bug] Multiple partition key on cosmos db is not supported/has a bug in python cosmos sdk Jun 7, 2023
@kashifkhan
Copy link
Member

Thank you for the feedback @kaushikc3 . We will investigate and get back to you asap.

@github-actions github-actions bot removed the needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. label Jun 7, 2023
@github-actions
Copy link

github-actions bot commented Jun 7, 2023

Thank you for your feedback. This has been routed to the support team for assistance.

@simorenoh
Copy link
Member

simorenoh commented Jun 7, 2023

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?

@kaushikc3
Copy link
Author

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.

@kaushikc3
Copy link
Author

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.

@simorenoh
Copy link
Member

@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.

@kaushikc3
Copy link
Author

Thank you @simorenoh for the quick answer. Will look forward to the July python sdk release. Thank you for clarifying.

@lmazuel
Copy link
Member

lmazuel commented Jun 12, 2023

@simorenoh let's also update https://feedback.azure.com/d365community/idea/286ff8dc-dbfa-ed11-a81c-000d3a0d3715 when it's out. Thanks!

@PramodValavala-MSFT PramodValavala-MSFT added Service Attention Workflow: This issue is responsible by Azure service team. Client This issue points to a problem in the data-plane of the library. and removed CXP Attention labels Jul 10, 2023
@github-actions github-actions bot added the needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team label Jul 10, 2023
@github-actions
Copy link

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @pjohari-ms @simorenoh @gahl-levy @bambriz.

@bambriz
Copy link
Member

bambriz commented Jul 13, 2023

@kaushikc3 the pr for subpartitioning is in review, should be available by end of July. PR 31121

@aksjadha-amdocs
Copy link

I am also facing the same issue, but meanwhile is there any alternative or workaround for this?
thanks in advance.

@bambriz
Copy link
Member

bambriz commented Oct 10, 2023

@kaushikc3 @aksjadha-amdocs PR to support subpartitioning (Multiple partition keys) has been merged see #31121

@xiangyan99 xiangyan99 added the issue-addressed Workflow: The Azure SDK team believes it to be addressed and ready to close. label Oct 13, 2023
@github-actions
Copy link

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.

@github-actions github-actions bot removed the needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team label Oct 13, 2023
@bambriz
Copy link
Member

bambriz commented Oct 18, 2023

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.

@bambriz bambriz closed this as completed Oct 18, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Jan 16, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Client This issue points to a problem in the data-plane of the library. Cosmos customer-reported Issues that are reported by GitHub users external to the Azure organization. issue-addressed Workflow: The Azure SDK team believes it to be addressed and ready to close. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Service Attention Workflow: This issue is responsible by Azure service team.
Projects
None yet
Development

No branches or pull requests

8 participants