Merged PR 1479858: $percentile & $median for $group accumulator

### Does this PR have any customer impact?

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

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

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

### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))

### Description

draft

----
#### AI description  (iteration 1)
#### PR Classification
New feature

#### PR Summary
This pull request introduces new aggregation functions and support for t-digest in the project.
- Added `bson_tdigest.c` to implement t-digest helper functions.
- Created new SQL aggregate functions in `group_aggregates--1.23-0.sql` and `group_aggregates_support--1.23-0.sql`.
- Updated `bson_aggregation_pipeline.c` to handle the new `$percentile` accumulator.
- Modified `metadata_cache.c` and `metadata_cache.h` to include OID for the new `BsonPercentileAggregateFunction`.
- Updated migration scripts `pg_helio_api--1.22-0--1.23-0.sql` and `pgmongo--1.22-0--1.23-0.sql` to include new SQL files.
This commit is contained in:
Xing Fan authored and Zhe Li committed 2025-01-15 07:48:41 +00:00
1 parent eed060110b
commit 722ef60784
23 files changed
+2689 -14

No files matched your search

@@ -109,6 +109,9 @@ void ParseInputDocumentForTopAndBottom(const bson_value_t *inputDocument,
bson_value_t *input,
bson_value_t *elementsToFetch,
bson_value_t *sortSpec, const char *opName);
void ParseInputDocumentForMedianAndPercentile(const bson_value_t *inputDocument,
bson_value_t *input, bson_value_t *p,
bson_value_t *method, bool isMedianOp);
void ValidateElementForNGroupAccumulators(bson_value_t *elementsToFetch, const
char *opName);
void ParseInputForNGroupAccumulators(const bson_value_t *inputDocument,
@@ -350,6 +350,8 @@ Oid ApiIndexStatsAggregationFunctionOid(void);
Oid BsonCurrentOpAggregationFunctionId(void);
Oid BsonMaxNAggregateFunctionOid(void);
Oid BsonMinNAggregateFunctionOid(void);
Oid BsonMedianAggregateFunctionOid(void);
Oid BsonPercentileAggregateFunctionOid(void);
/* Window functions*/
Oid BsonLinearFillFunctionOid(void);
@@ -15,7 +15,7 @@
#include <port/atomics.h>
#define MAX_FEATURE_NAME_LENGTH 255
#define MAX_FEATURE_COUNT 256
#define MAX_FEATURE_COUNT 258
/* Internal features that are not exposed */
#define INTERNAL_FEATURE_TYPE MAX_FEATURE_COUNT
@@ -256,6 +256,8 @@ typedef enum
FEATURE_STAGE_GROUP_ACC_FIRSTN_GT10,
FEATURE_STAGE_GROUP_ACC_LASTN,
FEATURE_STAGE_GROUP_ACC_LASTN_GT10,
FEATURE_STAGE_GROUP_ACC_MEDIAN,
FEATURE_STAGE_GROUP_ACC_PERCENTILE,
FEATURE_STAGE_GROUP_ACC_TOPN,
FEATURE_STAGE_INDEXSTATS,
FEATURE_STAGE_INVERSEMATCH,