Azure / azure-sdk-for-python

This repository is for active development of the Azure SDK for Python. For consumers of the SDK we recommend visiting our public developer docs at https://learn.microsoft.com/python/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-python.
MIT License
4.56k stars 2.78k forks source link

azure.cosmos hierarchical partition key bug #37638

Open Willem-J-an opened 5 days ago

Willem-J-an commented 5 days ago

Describe the bug See source here When using hierarchical partition key in azure cosmos, there seems to be a bug. The code checks that the amount of provided partition keys is not greater or equal than the amount of keys configured. The code fails if I provide 2 values for my 2 keys.

ValueError: 2 partition key components provided. Expected less than 2 components (number of container partition key definition components).

The docs show that a 3 part key is configured, and 3 values are provided.

To Reproduce Steps to reproduce the behavior:

  1. Configure hierarchical partition key on a container
  2. query it and provide all the corresponding key parts

Expected behavior I would expect if I configure two hierarchical keys, and provide the two corresponding hierarchical partition values that should work.

github-actions[bot] commented 5 days ago

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

Willem-J-an commented 5 days ago

The code now also misaligns with the error messages, expected value parts LESS THAN key parts; if I replace the >= operator with > it aligns to the message, and works.

        if len_pk_value > len_paths:
            raise ValueError(
                f"{len_pk_value} partition key components provided. Expected less than {len_paths} " +
                "components (number of container partition key definition components)."
            )
kashifkhan commented 5 days ago

Thank you for the feedback @Willem-J-an . We will investigate and get back to you asap.