Files
documentdb/pg_documentdb/include/aggregation/bson_query.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

42 lines
1.2 KiB
C

/*-------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
*
* include/bson/bson_query.h
*
* Common declarations of functions for handling bson queries.
*
*-------------------------------------------------------------------------
*/
#ifndef BSON_QUERY_H
#define BSON_QUERY_H
#include "io/bson_core.h"
/* The function that is called when dealing with a querySpec on a leaf
* query filter (e.g. "a.b" : <value>)
*/
typedef void (*ProcessQueryValueFunc)(void *context, const char *path, const
bson_value_t *value);
typedef void (*ProcessQueryFilterFunc)(void *context);
bool TraverseQueryDocumentAndGetId(bson_iter_t *queryDocument,
bson_value_t *idValue, bool errorOnConflict,
bool *hasNonIdFields);
void TraverseQueryDocumentAndProcess(bson_iter_t *queryDocument, void *context,
ProcessQueryValueFunc processValueFunc,
ProcessQueryFilterFunc processFilterFunc,
bool isUpsert);
static inline bool
IsBsonTypeCollationAware(bson_type_t type)
{
return type == BSON_TYPE_UTF8 || type == BSON_TYPE_DOCUMENT || type ==
BSON_TYPE_ARRAY;
}
#endif