Merged PR 1629302: [Composite POC] Fix up operators and type bracketing

### Does this PR have any customer impact?
Yes

### 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?

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

### Description
1) Fix up the remaining operators - implementations are sub-optimal
2) Add type bracketing options for all types and use them in operators
3) Add support for truncation of terms

TODO:
- Support recheck on the index for operators than just bounds
- Support N boundaries for index terms.

----
#### AI description  (iteration 1)
#### PR Classification
Bug fix

#### PR Summary
This pull request addresses issues with operators and type bracketing in BSON composite indexes.
- Added `bson_gin_index_types_core.c` to manage BSON type bounds for indexes.
- Updated `bson_gin_composite_entrypoint.c` to fix operator handling and apply type bracketing for various BSON index strategies.
<!-- GitOpsUserAgent=GitOps.Apps.Server.pullrequestcopilot -->
This commit is contained in:
Vinod Sridharan authored and Santiago Fernandez Madero committed 2025-04-10 10:29:08 -06:00
1 parent 4bc38f75c6
commit 5ad889feeb
11 files changed
+1028 -89

No files matched your search

@@ -26,6 +26,6 @@ typedef struct DollarRangeParams
bool isMaxInclusive;
} DollarRangeParams;
DollarRangeParams * ParseQueryDollarRange(pgbson *rangeFilter);
DollarRangeParams * ParseQueryDollarRange(pgbsonelement *filterElement);
#endif
@@ -78,7 +78,6 @@ Datum GenerateRootExistsTerm(const IndexTermCreateMetadata *);
Datum GenerateRootNonExistsTerm(const IndexTermCreateMetadata *);
Datum GenerateRootTruncatedTerm(const IndexTermCreateMetadata *);
Datum GenerateRootMultiKeyTerm(const IndexTermCreateMetadata *);
int32_t CompareBsonIndexTerm(BsonIndexTerm *left, BsonIndexTerm *right,
bool *isComparisonValid);
@@ -0,0 +1,19 @@
/*-------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
*
* include/opclass/bson_gin_index_types_core.h
*
* Common declarations of the serialization of index terms.
*
*-------------------------------------------------------------------------
*/
#ifndef BSON_GIN_INDEX_TYPES_CORE_H
#define BSON_GIN_INDEX_TYPES_CORE_H
bson_value_t GetUpperBound(bson_type_t type, bool *isUpperBoundInclusive);
bson_value_t GetLowerBound(bson_type_t type, bool *isUpperBoundInclusive);
bson_type_t GetBsonTypeNameFromStringForDollarType(const char *typeNameStr);
#endif