Cosmos Driver: Hierarchical Partition Key Support#4087
Draft
simorenoh wants to merge 4 commits intorelease/azure_data_cosmos-previewsfrom
Draft
Cosmos Driver: Hierarchical Partition Key Support#4087simorenoh wants to merge 4 commits intorelease/azure_data_cosmos-previewsfrom
simorenoh wants to merge 4 commits intorelease/azure_data_cosmos-previewsfrom
Conversation
API Change CheckAPIView identified API level changes in this PR and created the following API reviews |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds MultiHash EPK (Effective Partition Key) computation and prefix partition key routing infrastructure to the driver crate, enabling hierarchical partition key (HPK) support for containers with multiple partition key paths.
What changed
MultiHash EPK computation (
effective_partition_key.rs)Previously,
EffectivePartitionKey::compute()fell through to single-hash V2 forPartitionKeyKind::MultiHash, producing incorrect EPKs. MultiHash requires each component to be hashed independently — this PR adds that per-component hashing.PartitionKeyKind::MultiHasharm tocompute()routing to neweffective_partition_key_multi_hash_v2()hash_v2_to_epk()helper used by both single-hash and multi-hash pathstestdata/*.xmlfixturesPrefix EPK range computation (
effective_partition_key.rs)compute_range()for partial/prefix partition keys (fewer components than the container definition)[prefix_epk, prefix_epk + "FF")range covering all possible suffix completionsPrefix routing in PK range cache (
partition_key_range_cache.rs)resolve_partition_key_range_ids()that handles both full and prefix partition keysresolve_overlapping_ranges()→ multiple range IDs for fan-outTests
9 new unit tests covering:
Undefinedcomponent (partial HPK)compute_range()for full keys, prefix keys (1-of-3, 2-of-3), and single-hash (always point)Follow-up: FeedRange API (PR #3987)
PR #3987 introduces
feed_range_from_partition_key(), which currently uses the SDK'shash.rsto compute EPKs. For MultiHash containers, this hits the existing stub and returns incorrect results. Once that method is updated to route through the driver's EPK computation (as part of the SDK-to-driver cutover), it will get correct MultiHash support for free from this PR. Prefix HPK support for the FeedRange API (returning multiple feed ranges for partial keys) will additionally need thecompute_range()infrastructure added here.This is the first step of the end-to-end implementation of this feature. The remaining work, piecing together the operations to this logic and ensuring that queries can also use it, rely on the migration to the driver.