Files
documentdb/pg_documentdb/include/sharding/sharding.h
T
Cornelius Boateng 4da81c67e6 Merged PR 1588632: [engine][collation] Support for Aggregation, Find, Query Match on Sharded Collections
### Does this PR have any customer impact? No

### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc) Feature

### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes) No

### Are you introducing any new config? If yes, do you have tests with and without them being set? No

### ChangeLog (Refer [Template](../oss/CHANGELOG.md))

### Description
Support collation for aggregation and query match queries on sharded collections.
If the `shard key filter` is collation-aware, we make the query distributed and push it to all shards.

----
#### AI description  (iteration 1)
#### PR Classification
New feature: Collation support for aggregation and query match on sharded collections.

#### PR Summary
This pull request adds collation support for aggregation and query match operations on sharded collections.
- `bson_dollar_ops_collation_tests_runtime.sql`: Added tests for collation-aware shard key queries.
- `sharding.c`: Introduced logic to track collation-aware shard key fields and updated related functions.
- `query_operator.c`: Modified to include shard key filters only if they are not collation-sensitive.
- `bson_aggregation_pipeline.c`: Added collation-aware checks for shard key filters in aggregation pipelines.
- `bson_query.h`: Added utility function `IsBsonTypeCollationAware` to check if BSON types are collation-aware.
<!-- GitOpsUserAgent=GitOps.Apps.Server.pullrequestcopilot -->

Related work items: #3915171, #3922023
2025-04-10 10:29:08 -06:00

28 lines
917 B
C

/*-------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
*
* sharding/sharding.h
*
* Common declarations for sharding functions.
*
*-------------------------------------------------------------------------
*/
#ifndef SHARDING_H
#define SHARDING_H
#include "metadata/collection.h"
int64 ComputeShardKeyHashForDocument(pgbson *shardKey, uint64_t collectionId,
pgbson *document);
bool ComputeShardKeyHashForQuery(pgbson *shardKey, uint64_t collectionId, pgbson *query,
int64 *shardKeyHash, bool *isShardKeyCollationAware);
Expr * ComputeShardKeyExprForQueryValue(pgbson *shardKey, uint64_t collectionId, const
bson_value_t *queryDocument,
int32_t collectionVarno,
bool *isShardKeyCollationAware);
Expr * CreateShardKeyValueFilter(int collectionVarNo, Const *valueConst);
#endif