### 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
Version update for next release 1.23
### 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
----
#### AI description (iteration 1)
#### PR Classification
Code cleanup and refactor.
#### PR Summary
This pull request refactors the calculation of variance and covariance to improve code readability and maintainability.
- `src/aggregation/bson_aggregation_statistics.c`: Replaced multiple instances of `Decimal128` operations with more generic `BsonValue` operations, simplifying the code and reducing redundancy.
- Improved handling of different numeric types (e.g., `INT64`, `DOUBLE`) for various calculations.
- Consolidated error handling for arithmetic operations to use more consistent and descriptive macros.
### Does this PR have any customer impact?
no
### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
testing
### 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))
### Description
Move more tests to oss distributedd
----
#### AI description (iteration 1)
#### PR Classification
Test migration
#### PR Summary
This pull request adds a new test file to validate the `create_indexes_background` function with various scenarios.
- Added `commands_create_indexes_background.out` to test different cases of index creation, including valid and invalid specifications, error handling, and unique constraints.
### Does this PR have any customer impact?
no
### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
Perf
### 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?
No
### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))
### Description
Only generate cursorId if the query has a continuation. (seen to take ~2% backend CPU of a ycsb read workload).
Also remove some functions that are long deprecated.
----
#### AI description (iteration 1)
#### PR Classification
Performance improvement
#### PR Summary
This pull request aims to improve performance in cursor generation by removing deprecated functions and related tests.
- Removed deprecated cursor-related functions from `oss/pg_helio_api/src/commands/cursors.c`.
- Deleted test files `pgmongo/src/test/regress/expected/pgmongo_get_cursor_page_tests.out` and `pgmongo/src/test/regress/sql/pgmongo_get_cursor_page_tests.sql`.
- Updated `pgmongo/src/test/regress/expected/bson_aggregation_stage_merge_tests.out` to reflect changes in cursor ID handling.
- Added deprecation error messages for cursor-related functions in `pgmongo/src/function_stubs.c`.
### 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
----
#### AI description (iteration 1)
#### PR Classification
Test migration
#### PR Summary
This pull request adds a new test file to validate the behavior of unique indexes in a distributed environment.
- Added `oss/internal/pg_helio_distributed/src/test/regress/expected/bson_unique_index.out` to test various scenarios involving unique indexes, including creation, insertion, and constraint violations.
### 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
----
#### AI description (iteration 1)
#### PR Classification
Performance improvement for string aggregation operations.
#### PR Summary
This pull request refactors and optimizes string aggregation operations, focusing on performance improvements.
- Removed redundant functions and added new parsing and handling functions for `$regexFind`, `$regexMatch`, and `$regexFindAll` in `bson_expression_string_operators.c`.
- Refactored existing string operations like `$concat`, `$toUpper`, `$toLower`, `$strLenBytes`, `$strLenCP`, `$split`, `$trim`, `$ltrim`, and `$rtrim` to use a more efficient parsing and handling framework in `bson_expression_string_operators.c`.
- Introduced helper functions for parsing and evaluating string operators with one, two, and three operands in `bson_expression_string_operators.c`.
Related work items: #3458666
### Does this PR have any customer impact?
No
### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
Refactor
### 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?
Yes
### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))
### Description
Fix up add node to work - after add node create table fails - fix this up - This is because the reference tables for collections aren't replicated to the new node so we can't replicate the table + create shards on that node in the same command.
Check on create table if all shards have reference tables - if not call replicate_reference_tables on create.
----
#### AI description (iteration 1)
#### PR Classification
Bug fix
#### PR Summary
This pull request addresses an issue with node addition in a distributed system by ensuring metadata tables are properly replicated.
- `distributed_hooks.c`: Added `EnsureMetadataTableReplicatedCore` function to ensure metadata tables are replicated across nodes.
- `helio_distributed_init.c` (new file): Introduced initialization for distributed configurations, including a new GUC `EnableMetadataReferenceTableSync`.
- `pgmongo.c`: Moved read concern level definitions and configurations from `pg_helio_api` to `pgmongo`.
- `api_hooks.c`: Added `EnsureMetadataTableReplicated` function to check and replicate metadata tables.
- `create_collection_core.c` and `sharding.c`: Integrated `EnsureMetadataTableReplicated` to ensure metadata tables are handled during collection creation and sharding.
### 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
Delete directly from shard in delete one if available
----
#### AI description (iteration 1)
#### PR Classification
Code cleanup and deprecation.
#### PR Summary
This pull request deprecates the `command_delete_one` function and refactors the deletion logic to directly delete from shards if available.
- `oss/pg_helio_api/src/commands/delete.c`: Deprecated `command_delete_one` function and refactored deletion logic to use shard-specific tables.
- `oss/pg_helio_api/src/test/regress/expected/commands_delete.out` and `oss/pg_helio_api/src/test/regress/sql/commands_delete.sql`: Removed tests for the deprecated function and updated tests to use `find_and_modify` with the remove option.
- Deleted `pgmongo/src/test/regress/expected/commands_delete.out` and `pgmongo/src/test/regress/sql/commands_delete.sql` as they are no longer needed.
### 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
empty collection name check
----
#### AI description (iteration 1)
#### PR Classification
Bug fix to handle empty collection names.
#### PR Summary
This pull request adds checks to ensure that collection names are not empty, preventing invalid namespace errors.
- `src/metadata/collection.c`: Added a check to report an error if the collection name is empty.
- `src/commands/find_and_modify.c`: Added a check to report an error if the collection name is empty.
Related work items: #3463176
### Does this PR have any customer impact?
no
### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
refactoring
### 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))
NA
### Description
Move more tests to oss
This PR also moves few `mongo_catalog` and `mongo_api_v1` functions to helio
1- range operator is now moved to `helio_api_internal.@<>`
2- `helio_api_internal.collection_table` function is moved but original one is not deleted yet.
3- `helio_api_internal.bson_dollar_lookup_project` moved.
4- `mongo_api_internal.gin_bson_get_single_path_generated_terms` is now moved to `helio_api_internal.gin_bson_get_single_path_generated_terms`
5- `mongo_api_internal.gin_bson_get_wildcard_project_generated_terms` is now moved to `helio_api_internal.gin_bson_get_wildcard_project_generated_terms`
----
#### AI description (iteration 1)
#### PR Classification
Test migration
#### PR Summary
This pull request migrates 8 tests as part of the ongoing OSS test migration effort.
- Moved `bson_query_operator_tests_index_backcompat.out` and `bson_index_term_generation.sql` to `oss/internal/pg_helio_distributed/src/test/regress`.
- Added new test file `bson_aggregation_expression_variable_tests.out` with extensive BSON expression tests.
### 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
[oss] Test Cleanup removing invalid schemas from test
----
#### AI description (iteration 1)
#### PR Classification
Code cleanup to remove invalid schemas from test files.
#### PR Summary
This pull request cleans up test files by removing invalid schema names and adding validation to ensure they are not used.
- `validate_test_output.sh`: Added validation to check for invalid schema names and exit if found.
- `bson_aggregation_pipeline_stage_fill.out`, `bson_aggregation_stage_out_tests_2.out`, `bson_aggregation_pipeline_stage_fill.sql`, `bson_aggregation_stage_out_tests_2.sql`: Removed `mongo_catalog` from the search path.
- `bson_aggregation_pipeline_stage_fill.out`, `bson_aggregation_stage_out_tests_2.out` (in `pgmongo`): Adjusted search path to exclude `mongo_catalog`.
### Does this PR have any customer impact?
no
### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
refactoring
### 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?
no
### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))
NA
### Description
remove legacy errors completely
----
#### AI description (iteration 1)
#### PR Classification
Code cleanup
#### PR Summary
This pull request removes legacy MongoDB error handling code and all related references.
- Deleted `mongo_errors.h`.
- Removed `CheckNoMongoErrorCodeHeader` function and related calls from `scripts/validate_helio_extension_state.sh`.
- Updated `error_utils.c` to remove legacy MongoDB error handling logic.
- Deleted deprecated functions from `helio_distributed_test_helpers.sql` and `pgmongo_test_helpers.sql`.
- Updated expected test outputs in `helio_distributed_test_helpers.out` and `pgmongo_test_helpers.out` to reflect the removal of deprecated functions.
### 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
Enable $out stage GUC
----
#### AI description (iteration 1)
#### PR Classification
New feature
#### PR Summary
This pull request enables the `$out` aggregation stage by default in the system.
- Modified `oss/pg_helio_api/src/helio_api_init.c` to set `DEFAULT_ENABLE_OUT_STAGE` to `true`.
- Updated test files `oss/internal/pg_helio_distributed/src/test/regress/expected/bson_aggregation_stage_out_tests_2.out`, `oss/internal/pg_helio_distributed/src/test/regress/sql/bson_aggregation_stage_out_tests_2.sql`, and `pgmongo/src/test/helio_compat/expected/bson_aggregation_stage_out_tests_2.out` to remove GUC enablement steps and error checks.
### 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))
### Description
Start up fixes to support add node and rebalancing
- the cluster_data table didn't have a primary key - add it
- the index specs type was mismatched between current nodes and new nodes. Make them matched and handle back compat
With this at least new nodes can be added and rebalanced. After which new tables can be created.
We still cannot create tables after add node (this scenario is still broken at this point).
----
#### AI description (iteration 1)
#### PR Classification
Schema update to support node rebalancing.
#### PR Summary
This pull request updates the schema to facilitate node rebalancing in the cluster.
- `cluster_operations.c`: Added logic to conditionally alter types and re-add primary keys based on version checks.
- `start_postgres_server.sh` and `utils.sh`: Introduced `skipRegisterWorkerNode` flag and related functions to handle inactive nodes and shard management.
- `pgmongo--1.22-0--1.23-0.sql`: Added primary key to `pgmongo_cluster_data` and conditionally altered `index_spec_type_internal`.
- `collection_indexes_metadata--1.23-0.sql`: Added new attributes to `index_spec_type_internal`.
- `pg_helio_api--1.22-0--1.23-0.sql` and `pg_helio_distributed--1.22-0--1.23-0.sql`: Included schema changes and primary key addition.
### 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
Migrating 22 tests to Oss. So those tests run in both.
----
#### AI description (iteration 1)
#### PR Classification
Test migration
#### PR Summary
This pull request removes SQL test files related to BSON aggregation and order aggregates as part of the test migration process.
- Deleted `bson_aggregation_trigonometric_operators_tests.sql` containing tests for various BSON trigonometric operators.
- Deleted `bson_order_aggregates_tests.sql` containing tests for BSON order aggregates and related functions.
### 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
version update to start 1.22 release
----
#### AI description (iteration 1)
#### PR Classification
Version update to start the 1.23 release.
#### PR Summary
This pull request updates the project version to 1.23 and includes necessary changes to support the new release.
- Added release notes for version 1.23 in `docs/release_notes/pgmongo_1.23.md`.
- Updated version numbers in control files: `pg_helio_distributed.control`, `pg_helio_api.control`, `pg_helio_core.control`, and `pgmongo.control`.
- Added SQL migration scripts for version updates in `pg_helio_distributed`, `pg_helio_api`, `pg_helio_core`, and `pgmongo`.
- Updated SHA1 checksums for SQL scripts in `pgmongo/sql/sha1/`.
### 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
Test Migration PART-2
----
#### AI description (iteration 1)
#### PR Classification
Test migration.
#### PR Summary
This pull request removes test cases related to BSON aggregation arithmetic operators and expression variables as part of the test migration process.
- Removed all test cases from `pgmongo/src/test/regress/sql/bson_aggregation_arithmetic_operators_tests.sql`.
- Removed all expected output from `pgmongo/src/test/regress/expected/bson_aggregation_expression_variable_tests.out`.
### 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
[OSS] Test Migration PART-1
----
#### AI description (iteration 1)
#### PR Classification
Test migration.
#### PR Summary
This pull request adds new test cases for BSON aggregation comparison operators.
- Added extensive test cases in `pgmongo/src/test/helio_compat/expected/bson_aggregation_comparison_operators_tests.out` for `$cmp`, `$eq`, `$ne`, `$gt`, `$gte`, `$lt`, and `$lte` operators.
Related work items: #3494537
### 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)
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))
### Description
----
#### AI description (iteration 1)
#### PR Classification
New feature implementation for the `$setWindowFields` stage.
#### PR Summary
This pull request implements the `$first(N)` and `$last(N)` aggregation functions for the `$setWindowFields` stage.
- Added new aggregate functions in `oss/pg_helio_api/sql/udfs/aggregation/group_aggregates--1.21-0.sql` for `BSONFIRST`, `BSONLAST`, `BSONFIRSTN`, `BSONLASTN`, and their sorted variants.
Related work items: #2151585, #2151587
This PR includes two parts:
1. The design doc of $fill
2. The implementation of $fill using `rewrite` way. Refer design doc [here](https://msdata.visualstudio.com/CosmosDB/_git/pgmongo/pullrequest/1423500?_a=files&path=/docs/pgmongo/design_docs/data_plane/aggregation_stages/fill.md).
3. Extract bson_expression_partition_by_fields_get() as a common method. So that, some related changes are:
a. densify's parse stage is changed
b. densify's unit tests is changed due to method name change
c. densify's original method for partitionByFields is removed
**Noticed:**
This implementation is based on the impl of `$linearFill` and `$locf`.
### Does this PR have any customer impact?
no
### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
refactoring
### 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))
na
### Description
1. Move all legacy errors to new helio errors
2. Remove all refs to mongo_errors.h excluding error_utils.c , there is function which needs backword compatibility
3. Update `scripts/validate_helio_extension_state.sh` to enforce all validations on oss/pg_helio_api parent directory instead of individual sub directories
----
#### AI description (iteration 1)
#### PR Classification
Code cleanup and deprecation.
#### PR Summary
This pull request moves all error handling to `helio_errors` and removes references to `mongo_errors.h`, deprecating certain functions.
- `error_utils.c`: Deprecated `command_throw_mongo_error` and `command_convert_mongo_error_to_postgres` functions.
- `mongo_errors.h`: Removed Mongo error handling code and redefined error code checks.
- `validate_helio_extension_state.sh`: Updated validation script to remove checks for `mongo_errors.h`.
- Added new SQL functions for database commands in `kill_op--1.22-0.sql`, `get_shard_key_value--1.22-0.sql`, and `reindex--1.22-0.sql`.
- Updated test files to reflect deprecation changes in error handling functions.
### Does this PR have any customer impact?
No, but setting to true was
### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
Bugfix
### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes)
N/A
### 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))
N/A
### Description
Setting enableCollation to false by default
----
#### AI description (iteration 1)
#### PR Classification
Configuration change to set `enableCollation` to false by default.
#### PR Summary
This pull request modifies the default setting for collation support in the BSON initialization code.
- `oss/pg_helio_core/src/bson_init.c`: Changed `DEFAULT_ENABLE_COLLATION` from `true` to `false`.
### 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
[OSS] Port more errors to oss (M of N)
----
#### AI description (iteration 1)
#### PR Classification
Code cleanup and error handling improvement.
#### PR Summary
This pull request ports more error codes to the OSS (Open Source Software) version, replacing existing error codes with `ERRCODE_HELIO_*` equivalents and improving error detail logging.
- `bson_aggregation_output_pipeline.c`: Replaced various `Mongo*` error codes with `ERRCODE_HELIO_*` equivalents and updated error messages to use `errdetail_log`.
- `bson_aggregation_pipeline.c`: Updated error handling to use `ERRCODE_HELIO_*` equivalents and improved error detail logging.
- `bson_aggregation_nested_pipeline.c`: Replaced `Mongo*` error codes with `ERRCODE_HELIO_*` equivalents and enhanced error detail logging.
- `bson_project_operator.c`: Updated positional projection error handling to use `ERRCODE_HELIO_*` equivalents.
- `commands_update.out`: Updated expected error codes in test outputs to match new `ERRCODE_HELIO_*` values.
### 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
We cannot reuse the logic of firstN in the sort stag because the sort by key of the sort stage is a field, and the input and N of maxN are both expressions. maxN needs to sort the entire input expression.
for example :
input can be a expression:

N also can be a expression:

before the transition function, we need to evaluate input and n.
In the new implementation, we maintain a binaryHeap, the top of heap is maximum/minimum value.
For maxN:
**In transition funciton** :we need to maintain a small root heap and compare the current value with the top of the heap (minimum value). If the current value is greater than the top of the heap (minimum value), then we will pop the top of the heap and insert the current value.
**In the combine function,** each value of the left heap needs to be compared with the top of the right heap. If the conditions are met, the top of the right heap is popped out and the value is inserted. Each time, it is popped out from the left heap until the left heap is empty.
### Does this PR have any customer impact?
no
### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
refactor
### 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?
no
### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))
NA
### Description
Port to new errors in operators, planners, query, schema_validation directories
----
#### AI description (iteration 1)
#### PR Classification
Code cleanup to port to new error handling in specific directories.
#### PR Summary
This pull request updates error handling mechanisms in the `operators`, `planners`, `query`, and `schema_validation` directories.
- Modified `pgmongo/src/test/regress/expected/bson_query_operator_tests_index.out` to update error messages and hints for various BSON query operators.
### 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
mongo_errors.h should not be part of oss.
----
#### AI description (iteration 1)
#### PR Classification
Code cleanup
#### PR Summary
This pull request updates the validation script and replaces `mongo_errors.h` with `helio_errors.h` in various source files.
- `/scripts/validate_helio_extension_state.sh`: Added header file validation and updated `CheckNoMongoErrorCodes` function to include a header validation flag.
- Replaced `#include "utils/mongo_errors.h"` with `#include "utils/helio_errors.h"` in multiple source files including `shard_colocation.c`, `cluster_operations.c`, `distributed_hooks.c`, `sharding.c`, and several files in the `vector` directory.
### 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
[OSS] Port more error codes to OSS
----
#### AI description (iteration 1)
#### PR Classification
Code cleanup
#### PR Summary
This pull request ports error codes from MongoDB-specific codes to Helio-specific codes in the OSS project.
- `bson_json_schema_tree.c`: Replaced `Mongo` error codes with `ERRCODE_HELIO` equivalents.
- `bson_json_schema_validator.c`: Updated error code references to `ERRCODE_HELIO`.
- `collection.c`, `index.c`, `bson_gin_core.c`, `bson_gin_entrypoint.c`, `bson_gist_geospatial.c`, `bson_hashed_gin.c`, `bson_text_gin.c`, `gin_index_term.c`, `index_support.c`, `rum_exclusion.c`: Changed error code includes from `mongo_errors.h` to `helio_errors.h`.
- Removed `mongo_errors.h` include from `bson_gin_elemmatch.c`.
### Does this PR have any customer impact?
No
### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
Refactor
### 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?
No
### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))
NA
### Description
Port errors for geospatial, command, index_am folders
----
#### AI description (iteration 1)
#### PR Classification
Code cleanup
#### PR Summary
This pull request updates error codes and messages in the geospatial, command, and index_am folders to use the new `ERRCODE_HELIO` format.
- `src/geospatial/bson_geospatial_geonear.c`: Replaced `MongoTypeMismatch` and `MongoBadValue` with `ERRCODE_HELIO_TYPEMISMATCH` and `ERRCODE_HELIO_BADVALUE`.
- `src/commands/create_indexes.c`: Updated various error codes to `ERRCODE_HELIO_*` equivalents.
- `src/commands/find_and_modify.c`: Changed error codes to `ERRCODE_HELIO_FAILEDTOPARSE`.
- `src/commands/create_collection_view.c`: Replaced `MongoInvalidNamespace` and `MongoInvalidOptions` with `ERRCODE_HELIO_*` equivalents.
- `include/geospatial/bson_geospatial_private.h`: Updated include from `utils/mongo_errors.h` to `utils/helio_errors.h`.
### 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?
Yes
### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))
### Description
$densify stage is implemented with all 3 modes
- range
- partition
- full
All 7 functional tests are passing, few tests which are explain specific will be pass in next PR with the changes

----
#### AI description (iteration 1)
#### PR Classification
New feature: Adds a new `$densify` aggregation stage.
#### PR Summary
Introduces the `$densify` aggregation stage to create new documents where certain field values are missing.
- Added detailed documentation for `$densify` in `docs/pgmongo/design_docs/data_plane/aggregation_stages/densify.md`.
- Implemented core aggregation logic in `oss/pg_helio_api/src/aggregation/bson_densify.c`.
- Created SQL functions and aggregates for densify operations in `oss/pg_helio_api/sql/udfs/aggregation/bson_densify_aggregates--1.21-0.sql` and `oss/pg_helio_api/sql/udfs/aggregation/bson_densify_aggregates--latest.sql`.
- Updated versioning and inclusion of new SQL files in `oss/pg_helio_api/sql/pg_helio_api--1.20-0--1.21-0.sql` and `pgmongo/sql/pgmongo--1.20-0--1.21-0.sql`.
Related work items: #3436236
### 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)
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))
### Description
$top, $topN, $bottom, $bottomN implementation for $group and $setWindowFields
----
#### AI description (iteration 1)
#### PR Classification
New feature: Added support for `$topN` and `$bottomN` group expression operators.
#### PR Summary
This pull request introduces the `$topN` and `$bottomN` group expression operators to the aggregation pipeline.
- `bson_aggregation_pipeline.c`: Added `ParseInputDocumentForTopAndBottom` function to parse input documents for `$topN` and `$bottomN` operators, and integrated it into the existing aggregation handling logic.
- `mongo_errors.h`: Defined new error codes for handling errors related to the new operators.
Related work items: #2151574, #2151576, #2151596, #2151597, #2988406, #2988407, #2988413, #2988415
### 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)
No
### 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
support for $out aggregation stage in aggregation pipeline
what we not support :
1. On Mult coordinator setup source and target can not be same
----
#### AI description (iteration 1)
#### PR Classification
New feature
#### PR Summary
This pull request introduces the `$out` aggregation stage to the aggregation pipeline.
- `oss/pg_helio_api/src/aggregation/bson_aggregation_output_pipeline.c`: Added `HandleOut` function to handle the `$out` stage, including parsing, validation, and query mutation for outputting results to a specified collection.
Related work items: #1798580
### 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?
No
### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))
### Description
1. Introduces a backend process level collator cache so that we open a collator for a specific collation string once per backend process
2. Uses collation-based sort key generation for string for supporting $in which uses Hashmap for membership check. We wanted the keys of the HashMap to be collation-aware for UTF8 keys.
----
#### AI description (iteration 1)
#### PR Classification
Code enhancement to improve collation handling in string comparison.
#### PR Summary
This pull request refines the string comparison logic using ICU collation in the `bson_compare.c` file.
- `bson_compare.c`: Replaced custom ICU collator creation with `ucol_open` and added error handling for unsupported collations. Closed the collator after use to prevent resource leaks.
- `bson_compare.c`: Added a reference to the ICU documentation for better clarity.
Related work items: #3412412, #3431062, #3456172
### 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)
No
### 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
Enable $setWindowFields stage by default
----
#### AI description (iteration 1)
#### PR Classification
Enable `$setWindowFields` stage by default for version 1.22.
#### PR Summary
This pull request enables the `$setWindowFields` stage by default in the configuration for version 1.22.
- Modified `scripts/utils.sh` to remove the manual enabling of `helio_api.enableStageSetWindowFields`.
- Updated `oss/internal/pg_helio_distributed/src/test/regress/postgresql.conf` and `pgmongo/src/test/regress/postgresql.conf` to remove redundant enabling of `helio_api.enableStageSetWindowFields`.
- Changed `oss/pg_helio_api/src/helio_api_init.c` to set `DEFAULT_ENABLE_STAGE_SET_WINDOW_FIELDS` to `true` by default.
### Does this PR have any customer impact?
No
### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
Refactor
### 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?
No
### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))
### Description
- Port more error codes to OSS
- Disallow new backend tests in pgmongo
----
#### AI description (iteration 1)
#### PR Classification
Porting additional error codes to the open-source version.
#### PR Summary
This pull request ports more error codes to the open-source version and updates related test cases and error handling.
- Added multiple SQL test files in `/pgmongo/src/test/regress/pgmongo_test_baseline`.
- Updated error codes in `commands_create_index_geospatial.out` and `and3.out` test files.
- Modified error handling in `oss/pg_helio_api/src/collation/collation.c` to use new error codes.
- Adjusted error logging in `oss/pg_helio_api/src/commands/insert.c` to include SQL state.
### Does this PR have any customer impact?
No
### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
Refactor
### 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?
No
### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))
### Description
Port more errors to helio for more folders.
----
#### AI description (iteration 1)
#### PR Classification
Code cleanup to port error codes to Helio-specific error codes.
#### PR Summary
This pull request updates various error codes from Mongo-specific to Helio-specific error codes across multiple files.
- `vector_index_kind_impl.c`: Replaced `MongoBadValue` and `MongoFailedToParse` with `ERRCODE_HELIO_BADVALUE` and `ERRCODE_HELIO_FAILEDTOPARSE`.
- `shard_colocation.c`: Updated error codes from `MongoCommandNotSupported`, `MongoBadValue`, and `MongoFailedToParse` to Helio-specific equivalents.
- `bson_update_operators.c`: Changed error codes like `MongoTypeMismatch` and `MongoBadValue` to `ERRCODE_HELIO_TYPEMISMATCH` and `ERRCODE_HELIO_BADVALUE`.
- `parse_error.h`: Replaced `MongoTypeMismatch` with `ERRCODE_HELIO_TYPEMISMATCH`.
- `collection.c`: Updated error codes from `MongoBadValue` and `MongoInvalidNamespace` to Helio-specific equivalents.
### Does this PR have any customer impact?
No
### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
Refactor
### 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?
No
### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))
### Description
Move to helio error codes in pg-helio-core
Enforce hygiene in helio core
Move to helio errors
----
#### AI description (iteration 1)
#### PR Classification
Code cleanup
#### PR Summary
This pull request refactors error handling by replacing Mongo-specific error codes with Helio-specific error codes and updates error messages accordingly.
- Added `CheckNoMongoErrorCodes` function in `/scripts/validate_helio_extension_state.sh` to ensure no Mongo-specific error codes are used.
- Updated error codes and messages in `oss/pg_helio_core/src/query/bson_compare.c` to use Helio-specific codes.
- Modified error handling in `oss/pg_helio_core/src/types/pcre_regex.c` to replace Mongo error codes with Helio error codes.
- Replaced Mongo error codes with Helio error codes in `oss/pg_helio_core/src/io/pgbsonsequence.c`.
- Updated error codes in `oss/pg_helio_core/src/types/decimal128.c` to use Helio-specific codes.
### Does this PR have any customer impact?
No
### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
Testing
### 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?
No
### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))
### Description
Add more tests from Pgmongo -> pg_helio_distributed.
Move the dollar Ops tests to pg_helio_distributed.
----
#### AI description (iteration 1)
#### PR Classification
Test migration
#### PR Summary
This pull request migrates additional tests to the `pg_helio_distributed` module.
- Added extensive BSON dollar operations and JSON schema query tests in `pg_helio_distributed/src/test/regress/expected/bson_dollar_ops_json_schema_query_tests.out`.
### 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
Version update in preparation for 1.21 release
----
#### AI description (iteration 1)
#### PR Classification
Version update in preparation for 1.21 release.
#### PR Summary
This pull request updates the version numbers and prepares the project for the 1.21 release.
- Added release notes template in `/docs/release_notes/pgmongo_1.22.md`.
- Updated version numbers in control files: `/oss/internal/pg_helio_distributed/pg_helio_distributed.control`, `/oss/pg_helio_api/pg_helio_api.control`, `/oss/pg_helio_core/pg_helio_core.control`, and `/pgmongo/pgmongo.control`.
- Added SQL migration scripts for version updates in `/oss/internal/pg_helio_distributed/sql/pg_helio_distributed--1.21-0--1.22-0.sql`, `/oss/pg_helio_api/sql/pg_helio_api--1.21-0--1.22-0.sql`, `/oss/pg_helio_core/sql/pg_helio_core--1.21-0--1.22-0.sql`, and `/pgmongo/sql/pgmongo--1.21-0--1.22-0.sql`.
- Updated SHA1 checksums for SQL scripts in `/pgmongo/sql/sha1/`.
### 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
One time upgrade to allow existing flex clusters to create roles
----
#### AI description (iteration 1)
#### PR Classification
New feature to enable existing flex clusters to create roles.
#### PR Summary
This pull request introduces a one-time upgrade to allow existing flex clusters to create roles, specifically targeting the `azure_pg_admin` role.
- `cluster_operations.c`: Added logic to grant roles to `azure_pg_admin` during setup if certain conditions are met.
- `helio_api_init.c`: Introduced a new configuration variable `ClusterAdminRole` with a default value and updated initialization logic.
- `complete_pgmongo_upgrade--1.21-0.sql`: Created a new SQL function to complete the extension upgrade.
- `pgmongo_postgres_flex_userconfig.conf`: Added a new configuration entry for `clusterAdminRole`.
### 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
Update complete_upgrade to work even if cluster is readonly for full disk
If the control plane sets the cluster into readonly, we prohibit write operations at the planner level. However complete_upgrade should be successful to be able to move the clusters forward when they're on that state.
----
#### AI description (iteration 1)
#### PR Classification
Bug fix to ensure the `complete_upgrade` function works even if the cluster is in a read-only state due to full disk.
#### PR Summary
This pull request updates the `complete_upgrade` function to handle scenarios where the cluster is read-only due to a full disk, ensuring the upgrade process can still proceed.
- `cluster_operations.c`: Modified `command_complete_upgrade` to temporarily disable the read-only setting during the upgrade.
- `extension_upgrade_diskfull_readonly.sql` and `extension_upgrade_diskfull_readonly.out`: Added new regression tests to verify the upgrade process in read-only mode.
- `upgrade_schedule`: Included the new test case for disk full read-only upgrade scenario.
### 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
Run helio_compat tests in pgmongo
----
#### AI description (iteration 1)
#### PR Classification
Failing test setup for `helio_compat` tests in `pgmongo`.
#### PR Summary
This pull request sets up a baseline for running `helio_compat` tests in the `pgmongo` project, although the tests are still failing.
- Added expected output for various BSON expression evaluations in `pgmongo/src/test/helio_compat/expected/bson_expr_eval_tests.out`.
### Does this PR have any customer impact?
No
### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
Testing
### 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?
No
### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))
### Description
Port bson basic compare tests to the OSS distributed extension
----
#### AI description (iteration 1)
#### PR Classification
Porting tests to the open-source distributed extension.
#### PR Summary
This pull request ports the BSON basic compare tests to the open-source distributed extension.
- Removed test cases from `pgmongo/src/test/regress/expected/bson_dollar_ops_basic_compare_tests_explain_index_no_bitmap.out`.
### Does this PR have any customer impact?
No
### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
Refactoring
### 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))
### Description
Port 4 tests to helio_distributed and clean up the code to make them pass.
----
#### AI description (iteration 1)
#### PR Classification
Porting initial tests to a distributed environment.
#### PR Summary
This pull request ports the first four tests to a distributed environment, ensuring that the query evaluation functions work correctly in this setup.
- Added distributed test cases for various BSON expression evaluations in `src/test/regress/expected/bson_expr_eval_tests.out`.
### Does this PR have any customer impact?
No
### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
Refactor
### 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))
### Description
Prep for porting backend distributed tests
----
#### AI description (iteration 1)
#### PR Classification
Code cleanup and preparation for porting backend distributed tests.
#### PR Summary
This pull request removes obsolete code and prepares the codebase for porting backend distributed tests.
- Deleted `cluster_operations.c` and `version_utils.c` from `pgmongo/src`.
- Added new functions and triggers in `helio_distributed_test_helpers.sql` and `helio_distributed_test_helpers.out` for testing.
- Updated `cluster_operations.c` in `pg_helio_distributed` to include new cluster management functions.
- Added new SQL files for cluster operations and version utilities in `pg_helio_distributed`.
- Modified `pgmongo.c` to set up global variables for distributed functions and index build queue table creation.
### 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
Updated distributed_hooks.c
----
#### AI description (iteration 1)
#### PR Classification
Code cleanup to remove unnecessary include statements.
#### PR Summary
This pull request removes an unused include statement from the `distributed_hooks.c` file to improve code maintainability.
- `distributed_hooks.c`: Removed the unnecessary `#include <distributed/backend_data.h>` statement.
### Does this PR have any customer impact?
No
### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
Refactor
### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes)
Yes(ish)
### 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
Introduce pg_helio_distributed for distribution hooks and make pgmongo depend on that.
Also makes the rum_join_scan loading of private rum bits optional
----
#### AI description (iteration 1)
#### PR Classification
New feature: Introduce Helio Distributed Extension
#### PR Summary
This pull request introduces the Helio Distributed Extension, which adds distributed execution capabilities to the Helio system.
- Removed `shard_colocation.c` from `/pgmongo/src/distribution/` and added `distributed_hooks.c` in `/oss/private/pg_helio_distributed/src/distribution/`.
- Updated `api_hook_impl.c` to use new distributed hooks.
- Added new Makefile and build scripts for the Helio Distributed Extension in `/oss/private/pg_helio_distributed/`.
- Introduced new test validation scripts and configurations in `/oss/private/pg_helio_distributed/src/test/regress/`.
- Updated `pgmongo` Makefile to include the new distributed extension.