mirror of
https://github.com/FerretDB/documentdb.git
synced 2026-11-25 11:49:53 -05:00
### 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) Yes ### 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)) - Support for `$setWindowFields` aggregation pipeline stage ### Description This PR adds the support for `$setWindowFields` aggregation stage using the Postgres `Window aggregation` operators. For the first PR it only adds support with `$sum` aggregation operator. Next set of PRs will individually support all the other window aggregation operators supported by `$setWindowFields` stage. [TODO] Currently $sum is used as is (the way $group uses it), there is way to optimize this using the `Inverse Transition` functions for Window aggregation which modifies the aggregated state in a way to accomodate rows leaving the group in a moving window, which will be done later (this is done to make review on smaller set of files) Related work items: #2272584
15 lines
561 B
SQL
15 lines
561 B
SQL
|
|
CREATE OR REPLACE FUNCTION __API_CATALOG_SCHEMA__.bson_orderby(__CORE_SCHEMA__.bson, __CORE_SCHEMA__.bson)
|
|
RETURNS __CORE_SCHEMA__.bson
|
|
LANGUAGE c
|
|
IMMUTABLE PARALLEL SAFE STRICT
|
|
AS 'MODULE_PATHNAME', $function$command_bson_orderby$function$;
|
|
|
|
|
|
-- ORDER BY operator function for $setWindowFields
|
|
CREATE OR REPLACE FUNCTION helio_api_internal.bson_orderby_partition(__CORE_SCHEMA__.bson, __CORE_SCHEMA__.bson, boolean)
|
|
RETURNS __CORE_SCHEMA__.bson
|
|
LANGUAGE c
|
|
IMMUTABLE PARALLEL SAFE STRICT
|
|
AS 'MODULE_PATHNAME', $function$bson_orderby_partition$function$;
|