mirror of
https://github.com/FerretDB/documentdb.git
synced 2026-11-25 19:59:54 -05:00
### Does this PR have any customer impact? No ### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc) Features ### 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? Yes ### ChangeLog (Refer [Template](../oss/CHANGELOG.md)) ### Description - Add support for a top level current_op command that calls the aggregation function and forms a command response - Add support for joining between regular tables and documentdb tables. In this mode, we'll still require a query to be exclusively for find/aggregate etc, but we can put those queries in a CTE/Subquery and join with other find/aggregate/postgres queries and apply regular postgres join semantics. ---- #### AI description (iteration 1) #### PR Classification New feature #### PR Summary This pull request introduces new features for handling `current_op` and joining with DocumentDB tables, including support for nested aggregation functions. - Added `BuildAggregateSpecFromCommandSpec` and `command_current_op` functions in `src/commands/current_op.c` to handle new aggregation specifications. - Implemented `MutateQueryAggregatorFunction` and `ExpandNestedAggregationFunction` in `src/planner/documents_planner.c` to support nested aggregation queries. - Added new test cases in `src/test/regress/sql/bson_aggregation_functions_nested_tests.sql` and `src/test/regress/expected/bson_aggregation_functions_nested_tests.out`. - Introduced feature flag `allowNestedAggregationFunctionInQueries` in `src/configs/feature_flag_configs.c` to control nested aggregation functionality. - Created new UDFs in `sql/udfs/commands_diagnostic/current_op--0.102-0.sql` for the `currentOp` aggregation stage. <!-- GitOpsUserAgent=GitOps.Apps.Server.pullrequestcopilot -->
23 lines
1.2 KiB
SQL
23 lines
1.2 KiB
SQL
/* Add functions for the currentOp aggregation stage */
|
|
/* Spec contains { allUsers: <boolean>, idleConnections: <boolean>, idleCursors: <boolean>, idleSessions: <boolean>, localOps: <boolean> } */
|
|
DROP FUNCTION IF EXISTS __API_SCHEMA_INTERNAL_V2__.current_op_aggregation;
|
|
CREATE OR REPLACE FUNCTION __API_SCHEMA_INTERNAL_V2__.current_op_aggregation(p_spec __CORE_SCHEMA_V2__.bson, OUT document __CORE_SCHEMA_V2__.bson)
|
|
RETURNS SETOF __CORE_SCHEMA_V2__.bson
|
|
LANGUAGE c
|
|
VOLATILE STRICT ROWS 100
|
|
AS 'MODULE_PATHNAME', $function$command_current_op_aggregation$function$;
|
|
|
|
DROP FUNCTION IF EXISTS __API_SCHEMA_INTERNAL_V2__.current_op_worker;
|
|
CREATE OR REPLACE FUNCTION __API_SCHEMA_INTERNAL_V2__.current_op_worker(p_spec __CORE_SCHEMA_V2__.bson, OUT document __CORE_SCHEMA_V2__.bson)
|
|
RETURNS __CORE_SCHEMA_V2__.bson
|
|
LANGUAGE c
|
|
VOLATILE STRICT
|
|
AS 'MODULE_PATHNAME', $function$command_current_op_worker$function$;
|
|
|
|
DROP FUNCTION IF EXISTS __API_SCHEMA_V2__.current_op_command;
|
|
CREATE OR REPLACE FUNCTION __API_SCHEMA_V2__.current_op_command(p_spec __CORE_SCHEMA_V2__.bson, OUT document __CORE_SCHEMA_V2__.bson)
|
|
RETURNS __CORE_SCHEMA_V2__.bson
|
|
LANGUAGE c
|
|
VOLATILE STRICT
|
|
AS 'MODULE_PATHNAME', $function$command_current_op$function$;
|