mirror of
https://github.com/FerretDB/documentdb.git
synced 2026-11-25 11:49:53 -05:00
### 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) UDF ### Are you introducing any new config? If yes, do you have tests with and without them being set? No ### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md)) ### Description add a window operator, $integral ---- #### AI description (iteration 1) #### PR Classification New feature: Adds a new window operator `$integral` for aggregation. #### PR Summary This pull request introduces the `$integral` window operator to compute integrals using the trapezoidal rule in BSON aggregation. - Added `BsonIntegralAggState` structure and related functions in `bson_aggregates.c` to handle integral calculations. - Implemented `HandleDollarIntegralWindowOperator` in `bson_aggregation_window_operators.c` to process the new `$integral` operator. - Updated SQL UDFs in `group_aggregates_support--latest.sql` and `group_aggregates--latest.sql` to include the new `bson_integral_transition` and `bson_integral_final` functions. - Added `BsonIntegralAggregateFunctionOid` in `metadata_cache.c` and `metadata_cache.h` for function OID retrieval. - Exposed `GetDecimal128FromInt64` in `decimal128.c` and `decimal128.h` for converting integers to BSON decimal128 format. Related work items: #3343290
44 lines
1.7 KiB
SQL
44 lines
1.7 KiB
SQL
CREATE OR REPLACE AGGREGATE helio_api_internal.BSONCOVARIANCEPOP(__CORE_SCHEMA__.bson, __CORE_SCHEMA__.bson)
|
|
(
|
|
SFUNC = helio_api_internal.bson_covariance_pop_samp_transition,
|
|
FINALFUNC = helio_api_internal.bson_covariance_pop_final,
|
|
MSFUNC = helio_api_internal.bson_covariance_pop_samp_transition,
|
|
MFINALFUNC = helio_api_internal.bson_covariance_pop_final,
|
|
MINVFUNC = helio_api_internal.bson_covariance_pop_samp_invtransition,
|
|
stype = bytea,
|
|
mstype = bytea,
|
|
COMBINEFUNC = helio_api_internal.bson_covariance_pop_samp_combine,
|
|
PARALLEL = SAFE
|
|
);
|
|
|
|
|
|
CREATE OR REPLACE AGGREGATE helio_api_internal.BSONCOVARIANCESAMP(__CORE_SCHEMA__.bson, __CORE_SCHEMA__.bson)
|
|
(
|
|
SFUNC = helio_api_internal.bson_covariance_pop_samp_transition,
|
|
FINALFUNC = helio_api_internal.bson_covariance_samp_final,
|
|
MSFUNC = helio_api_internal.bson_covariance_pop_samp_transition,
|
|
MFINALFUNC = helio_api_internal.bson_covariance_samp_final,
|
|
MINVFUNC = helio_api_internal.bson_covariance_pop_samp_invtransition,
|
|
stype = bytea,
|
|
mstype = bytea,
|
|
COMBINEFUNC = helio_api_internal.bson_covariance_pop_samp_combine,
|
|
PARALLEL = SAFE
|
|
);
|
|
|
|
|
|
CREATE OR REPLACE AGGREGATE helio_api_internal.BSONDERIVATIVE(__CORE_SCHEMA__.bson, __CORE_SCHEMA__.bson, bigint)
|
|
(
|
|
SFUNC = helio_api_internal.bson_derivative_transition,
|
|
FINALFUNC = helio_api_internal.bson_integral_derivative_final,
|
|
stype = bytea,
|
|
PARALLEL = SAFE
|
|
);
|
|
|
|
|
|
CREATE OR REPLACE AGGREGATE helio_api_internal.BSONINTEGRAL(__CORE_SCHEMA__.bson, __CORE_SCHEMA__.bson, bigint)
|
|
(
|
|
SFUNC = helio_api_internal.bson_integral_transition,
|
|
FINALFUNC = helio_api_internal.bson_integral_derivative_final,
|
|
stype = bytea,
|
|
PARALLEL = SAFE
|
|
); |