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

Added Hierarchical Partition Key Support #23919

Merged
merged 9 commits into from
Feb 2, 2023

Conversation

v1k1
Copy link
Contributor

@v1k1 v1k1 commented Nov 18, 2022

Packages impacted by this PR

@azure/cosmos

Issues associated with this PR

#23416

Describe the problem that is addressed by this PR

Added Hierarchical Partition Key Support

  1. Refactored Definition of PartitionKey.
  • Old definition - type PartitionKey = PartitionKeyDefinition | string | number | unknown;
  • New definition - type PartitionKey = PrimitivePartitionKeyValue | PrimitivePartitionKeyValue[];
  • The main change here is
    a) Separating out PartitionKeyDefinition [May seem like a breaking change. But the actual functions which need PartitionKeyDefinition were always taking PartitionKeyDefinition as an input i.e. ContainerDefinition, the existing definition seems confusing.]
    b) Removal of unknown from definition (along with adding boolean). Defining it as PartitionKeyDefinition | string | number | unknown was effectively equivalent to unknown, since or of anything with unknown is unknown. Which essentially means we had no structure upon PartitionKey. This seems like a huge bug.
  1. Introduced PartitionKeyInternal to create a boundary beyond with PartitionKey would be sanitized. The idea is to use ClientContext as that boundary.
  2. Changed bulk/batch api Operation/OperationInput DTOs partitionKey field to PartitionKey type.
  3. Clearly defined order for choosing partitionKey for an operation during bulk api. Now if the user has provided partitionKey in OperationInput it will be used, if not it will be derived from resource body (for create and upsert).
  4. Added logic for MultiHash calculation.
  5. Changed FeedOption.partitionKey filed to PartitionKey type.

[[Bugs fixes]]

  1. In bulk api, The case when partition key path has escaped characters was not handled. In batch.ts -> deepFind() method.
  2. In bulk/batch api Operation/OperationInput DTOs were inconsistent in supporting type of partition key values.

What are the possible designs available to address the problem? If there are more than one possible design, why was the one in this PR chosen?

Are there test cases added in this PR? (If not, why?)

Yes

Provide a list of related PRs (if any)

Command used to generate this PR:**(Applicable only to SDK release request PRs)

Checklists

  • Added impacted package name to the issue description
  • Does this PR needs any fixes in the SDK Generator?** (If so, create an Issue in the Autorest/typescript repository and link it here)
  • Added a changelog (if necessary)

@ghost ghost added the Cosmos label Nov 18, 2022
@v1k1 v1k1 force-pushed the hierarchical-partition branch from 79df02f to 5014b4f Compare November 18, 2022 13:22
@v1k1 v1k1 marked this pull request as draft November 22, 2022 08:24
@v1k1 v1k1 force-pushed the hierarchical-partition branch from a89af0d to 8ad5527 Compare November 23, 2022 05:58
@v1k1 v1k1 force-pushed the hierarchical-partition branch from e697d1b to 076765b Compare January 11, 2023 12:23
@azure-sdk
Copy link
Collaborator

API change check

APIView has identified API level changes in this PR and created following API reviews.

azure-cosmos

@v1k1 v1k1 marked this pull request as ready for review January 20, 2023 09:56
Copy link

@abkolant-MSFT abkolant-MSFT left a comment

Choose a reason for hiding this comment

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

LGTM

@sajeetharan sajeetharan merged commit ec75d88 into Azure:main Feb 2, 2023
v1k1 added a commit that referenced this pull request Feb 9, 2023
sajeetharan pushed a commit that referenced this pull request Feb 9, 2023
Reverts #23919
These changes are reverted so that "Hierarchical Partition Feature" can
be released separately as a beta package to selected customers. These
changes will be merged to main trunk after the 'beta testing' phase.
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.

9 participants