### 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?
### ChangeLog (Refer [Template](../oss/CHANGELOG.md))
### Description
Change signature of `bson_query_match` with `let` and `collation` support to match other internal functions.
Fix schema name for pgmongo.
----
#### AI description (iteration 1)
#### PR Classification
New feature: Collation support for query match in unsharded collections.
#### PR Summary
This pull request adds collation support for query match operations in unsharded collections, ensuring proper collation enforcement.
- Modified `bson_query_match` function calls in `/pgmongo/src/test/docdb_compat/expected/bson_dollar_ops_collation_tests_runtime.out` to adjust collation parameters.
- Updated collation parameters in `bson_query_match` function calls in `/oss/internal/pg_documentdb_distributed/src/test/regress/expected/bson_dollar_ops_collation_tests_runtime.out`.
- Adjusted SQL test cases in `/oss/internal/pg_documentdb_distributed/src/test/regress/sql/bson_dollar_ops_collation_tests_runtime.sql` to reflect new collation support.
<!-- GitOpsUserAgent=GitOps.Apps.Server.pullrequestcopilot -->
Related work items: #3914004
### 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?
### ChangeLog (Refer [Template](../oss/CHANGELOG.md))
### Description
Index fix
----
#### AI description (iteration 1)
#### PR Classification
Bug fix
#### PR Summary
This pull request addresses an issue with index statistics in the `pg_documentdb` project.
- `src/commands/create_indexes.c`: Added `UpdateIndexStatsForPostgresIndex` function to update index statistics for unique indexes and integrated it into various index creation functions.
- `src/commands/create_indexes_background.c`: Updated to set statistics for unique indexes after index creation.
- `src/configs/feature_flag_configs.c`: Introduced a new feature flag `disable_statistics_for_unique_columns` to control the statistics update behavior.
- `include/commands/create_indexes.h`: Declared the new `UpdateIndexStatsForPostgresIndex` function.
<!-- GitOpsUserAgent=GitOps.Apps.Server.pullrequestcopilot -->
### 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; yes
### ChangeLog (Refer [Template](../oss/CHANGELOG.md))
### Description
Support `collation` with query operator using an internal UDF:
```
bson_query_match(document bson, query bson, collationString text, variableSpec bson)
```
Enable feature with `EnableCollationAndLetForQueryMatch` GUC.
Collation on sharded collections with collation-aware shard keys not supported yet.
----
#### AI description (iteration 1)
#### PR Classification
New feature
#### PR Summary
This pull request adds collation support for query operators in the engine.
- `query_operator.c`: Added logic to handle collation strings in BSON query operators and expanded function to support collation and variable specifications.
- `metadata_cache.c`: Introduced a new function to get the OID of `bson_query_match` with collation and let arguments.
- `feature_flag_configs.c`: Added a new feature flag to enable collation and let for write commands.
- `bson_query_match--0.102.sql` and `bson_query_match--latest.sql`: Added new SQL functions to support collation in BSON queries.
- `documents_planner.c`: Updated planner to recognize and handle the new collation and let functionality in queries.
<!-- GitOpsUserAgent=GitOps.Apps.Server.pullrequestcopilot -->
### Does this PR have any customer impact?
No
### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
Infra
### 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?
### ChangeLog (Refer [Template](../oss/CHANGELOG.md))
### Description
If the extension is at a higher version and it rolls back to a previous schema, then we should skip downgrades to the schema by a default version.
----
#### AI description (iteration 1)
#### PR Classification
Code enhancement to skip downgrading internal extensions from the latest version.
#### PR Summary
This pull request introduces a mechanism to skip downgrading internal extensions if they are already at the latest version.
- `src/infrastructure/process_utility_hook.c`: Added logic to check and skip downgrading if the installed version is newer than the target version.
- `src/pgmongo.c`: Introduced a new configuration variable `pgmongo.skip_extension_downgrade_check` to control the downgrade check behavior.
- `src/test/regress/sql/extension_upgrade_cluster_version.sql` and `src/test/regress/expected/extension_upgrade_cluster_version.out`: Added tests to verify the new behavior of skipping downgrades.
- `src/test/regress/bin/normalize.sed`: Updated normalization script to handle new version format in test outputs.
<!-- GitOpsUserAgent=GitOps.Apps.Server.pullrequestcopilot -->
### 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] Fix TTL indexes in documentdb
This moves the function to C and instead of querying the indexes and then getting the collection shards from pg_dist_shard table, it uses the C hook to get the table shards where for non-distributed it returns the base table and then uses that information to drop the expired records.
----
#### AI description (iteration 1)
#### PR Classification
Bug fix
#### PR Summary
This pull request addresses issues with TTL indexes in DocumentDB by refactoring and optimizing the deletion of expired rows.
- `ttl_index.c`: Refactored the function to delete expired rows, added a new function `delete_expired_rows`, and optimized the deletion process.
- `ttl_support_functions--latest.sql` and `delete_expired_rows--latest.sql`: Replaced PL/pgSQL procedures with C language implementations for better performance.
- `collection.c`: Moved the function `GetMongoCollectionShardOidsAndNames` from `coll_stats.c` to `collection.c` for better organization.
### Does this PR have any customer impact?
No
### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
Feature counter
### 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
### ChangeLog (Refer [Template](../oss/CHANGELOG.md))
No
### Description
Adding feature counter for sort by id to make decisions about sort by id pushdown to primary key optimization.
### Does this PR have any customer impact?
Yes
### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
Feature, 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
### ChangeLog (Refer [Template](../oss/CHANGELOG.md))
### Description
### Introduce new field "**exact**" in vector search spec to specify whether to run ENN or ANN search.
[exact field spec](https://www.mongodb.com/docs/atlas/atlas-vector-search/vector-search-stage/#fields)
### Value can be one of the following, defaults to false.
- false - to run ANN search
- true - to run ENN search
### Example
`{ "k": 1, "path": "vect", "filter": {"attr": {"$eq":1}}, "exact": true, "efSearch": 40 }`
----
#### AI description (iteration 1)
#### PR Classification
Code enhancement for filter selectivity in vector search queries.
#### PR Summary
This pull request enhances the filter selectivity mechanism in vector search queries by adding new functions and improving existing ones.
- `bson_aggregation_vector_search.c`: Added functions to calculate filter selectivity and handle vector search options, including `AddEmptySearchParamFunctionToQuery` and `GetFilterSelectivity`.
- `index_support.c`: Added logic to identify vector search queries in the planner.
- `system_configs.c`: Introduced new configuration variables for maximum filter selectivity and document count.
- `documents_planner.c`: Enhanced planner to handle vector search queries based on selectivity.
- `vector_common.h`: Declared new configuration variables for vector filter runtime sort selectivity and document count.
<!-- GitOpsUserAgent=GitOps.Apps.Server.pullrequestcopilot -->
### 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
### ChangeLog (Refer [Template](../oss/CHANGELOG.md))
Improve Perf in $lookup with let stage with nested join pipeline
### Description
Today the pipeline `$match` stage is not inlined with lookup right collection query in case it has `$expr` and let expression. Move this to right query if `$match` is the first non-inlined stage.
This improves the JOIN criteria and fetches lesser documents from right collection. We have seen cx cases where very small set of docucments can breach the 100 MB document limit otherwise.
----
#### AI description (iteration 1)
#### PR Classification
Code optimization and cleanup.
#### PR Summary
This pull request improves the handling of `$let` with `$lookup` in the aggregation pipeline by simplifying and optimizing the code.
- Removed the `QueryDocumentHasExpr` function and simplified the `CanInlineLookupStageMatch` function in `bson_aggregation_pipeline.c`.
- Enhanced the `OptimizeLookup` function to build and use `$let` expressions more efficiently in `bson_aggregation_nested_pipeline.c`.
- Simplified the `ProcessLookupCoreWithLet` function to directly use variables from the left query in `bson_aggregation_nested_pipeline.c`.
<!-- GitOpsUserAgent=GitOps.Apps.Server.pullrequestcopilot -->
### 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?
Yes
### ChangeLog (Refer [Template](../oss/CHANGELOG.md))
### Description
To do iterative search, this is a different approach and trying to see if we can do it better to load fewer documents. This change introduces only the parser changes behind a feature switch to do a different iterative search. The remaining planner and exec changes will be done in subsequent PRs.
----
#### AI description (iteration 1)
#### PR Classification
New feature: Parser changes for iterative search using Vector DiskANN.
#### PR Summary
This pull request introduces parser changes to support iterative search using Vector DiskANN.
- Added `bson_aggregation_pipeline_vector_diskann_planner.out` with test cases for inserting and querying documents using Vector DiskANN.
- Added `bson_aggregation_pipeline_vector_diskann_planner.sql` with SQL scripts for creating functions, inserting documents, and performing search operations using Vector DiskANN.
<!-- GitOpsUserAgent=GitOps.Apps.Server.pullrequestcopilot -->
### Does this PR have any customer impact?
Yes
### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
Bugfix
### 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
### ChangeLog (Refer [Template](../oss/CHANGELOG.md))
### Description
- Vector search pushdown to vector index was broken in OSS.
- Add option to force push vector search to vector index.
----
#### AI description (iteration 2)
#### PR Classification
Bug fix and new feature.
#### PR Summary
This pull request fixes vector search for OSS and adds support for force pushdown of vector index.
- Added new test files `bson_aggregation_pipeline_tests_vector_hnsw_planner.out` and `bson_aggregation_pipeline_tests_vector_hnsw_planner.sql` for vector search and HNSW index.
- Updated `index_support.c` to include support for vector index pushdown, including new functions `UpdateIndexListForVector`, `MatchIndexPathForVector`, and `ThrowNoVectorIndexFound`.
<!-- GitOpsUserAgent=GitOps.Apps.Server.pullrequestcopilot -->
### 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?
### ChangeLog (Refer [Template](../oss/CHANGELOG.md))
### Description
Clean up dead vector code - the score calculation is now embedded in the document.
----
#### AI description (iteration 1)
#### PR Classification
Code cleanup
#### PR Summary
This pull request removes dead vector code from the project, simplifying the codebase and improving maintainability.
- Removed `CreateFCInfoForScoreCalculation` and related logic from `src/vector/vector_utilities.c`.
- Deleted `SearchQueryEvalDataWorker` struct and associated functions from `include/vector/vector_utilities.h`.
- Cleaned up vector search data handling in `src/customscan/custom_query_scan.c`.
- Removed vector search query data extraction logic from `src/opclass/index_support.c`.
<!-- GitOpsUserAgent=GitOps.Apps.Server.pullrequestcopilot -->
### 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? Yes
### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))
### Description
Store the value of $$NOW in the variable spec as `now`.
Pass it through the ParseAggregationContext to be utilized by operators that implement the new aggregation framework.
Persist value in the cursor's continuation document to be used for get_more queries.
Enable/Disable with `EnableNowSystemVariable` GUC.
----
#### AI description (iteration 1)
#### PR Classification
New feature
#### PR Summary
This pull request introduces the `NOW_SYS_VARIABLE` to the BSON aggregation pipeline, allowing the use of the current timestamp in aggregation operations.
- Modified `bson_aggregation_pipeline_tests_add_to_set_group.out` to include `NOW_SYS_VARIABLE` in the BSON expressions for various aggregation operations.
Related work items: #3613264, #3613268
### Does this PR have any customer impact?
Yes
### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
Bugfix
### 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
To be updated. Meanwhile, please see the text_indexes.md file in the changeset for what motivated this change, and also a brief description of the same.
----
#### AI description (iteration 1)
#### PR Classification
Bug fix
#### PR Summary
This pull request fixes the `mongorestore` functionality for collections with text indexes by handling the `_fts` and `_ftsx` metadata terms correctly.
- Added documentation on text indexes in `PGMongo` in `docs/pgmongo/design_docs/data_plane/indexing/text_indexes.md`.
- Updated `oss/pg_helio_api/src/metadata/index.c` to handle `_fts` and `_ftsx` terms in index specifications.
- Modified `oss/pg_helio_api/src/commands/create_indexes.c` to correctly generate index expressions and handle text index options.
- Updated `docs/pgmongo/design_docs/data_plane/indexing/toc.yml` to include the new text indexes documentation.
### Does this PR have any customer impact?
Yes. This PR provides the option of "allChangesForCluster" to be able to track all the changes happening in the cluster with a change stream cursor.
### 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
first version of allChangesForCluster implementation
----
#### AI description (iteration 1)
#### PR Classification
New feature
#### PR Summary
Implemented the first version of the `allChangesForCluster` feature in the change stream.
- `change_stream_wal_utils.c`: Added logic to track changes for the entire cluster and refactored relation ID retrieval.
- `change_stream_aggregation_stage.c`: Updated context initialization to handle `allChangesForCluster` and added error handling for missing collections.
- `change_stream_decoding_utils.c`: Enhanced event building to support cluster-wide change tracking and added a function to get collection by relation ID.
- `change_stream.h`: Extended `ChangeStreamEvent` and `ChangeStreamSpec` structures to include cluster-wide tracking.
- Updated tests in `pgmongo_change_stream_crud_tests.sql` and `pgmongo_change_stream_crud_tests.out` to reflect the new feature.
* Merged PR 1565985: [OSS] Enable DBStats and CollStats in documentdb
### Does this PR have any customer impact?
Yes
### 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
Enable DBStats, CollStats and indexStats in DocumentDB. These were partially broken due to their dependence on Citus. Add appropriate hooks to ensure that Distributed continues to work.
Also clean up the code reuse of run_command_on_all_nodes across the 4 diagnostic commands.
CurrentOp and index builds are also broken but will be tackled in a separate change.
----
#### AI description (iteration 1)
#### PR Classification
New feature
#### PR Summary
This pull request enables the `DBStats` and `CollStats` commands in DocumentDB.
- `db_stats.c` and `coll_stats.c`: Refactored functions to retrieve shard OIDs and names, returning boolean status.
- `distributed_hooks.c`: Added core function to get shard IDs and names for a collection.
- Added new regression tests in `bson_aggregation_pipeline_diagnostic_command_tests.out` to validate `DBStats` and `CollStats` functionality.
* Merged PR 1565678: Updated README to remove architecture images per PGCA guidelines
### Does this PR have any customer impact?
No.
### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
Documentation
### 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
Per PGCA guidelines, we are temporarily removing the architecture image and replacing it with an approved one soon.
----
#### AI description (iteration 1)
#### PR Classification
Documentation update
#### PR Summary
This pull request updates the README to comply with PGCA guidelines by removing architecture images.
- `oss/README.md`: Removed the architecture image.
* DocumentDB sync sha=f3b8a6ec5
---------
Co-authored-by: Vinod Sridharan <visridha@microsoft.com>
Co-authored-by: Patty Chow <patty.chow@microsoft.com>
### 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))
NA
### Description
- support preserveNullAndEmptyArrays of unwind for lookup optimization with LEFT JOIN and COALESCE expression while merging so that we don't end up with NULL values for rows that don't have matching rows
----
#### AI description (iteration 1)
#### PR Classification
Code optimization
#### PR Summary
This pull request optimizes the lookup and unwind stages in the aggregation pipeline by allowing certain lookups to be inlined with unwind stages.
- `bson_aggregation_nested_pipeline.c`: Added logic to check if lookup stage can be inlined with unwind stage, including handling of various unwind options.
- `bson_aggregation_stage_lookup_tests.out`: Added new test cases to verify the inlining behavior of lookup and unwind stages.
### 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))
### Description
Migrate tests to documentdb and clean helio references from source
----
#### AI description (iteration 1)
#### PR Classification
Code cleanup and migration of tests.
#### PR Summary
This pull request migrates tests from `helio` to `documentdb` and removes all references to `helio` from the source code.
- `oss/pg_documentdb/src/test/regress/expected/commands_update.out`: Replaced all `helio` references with `documentdb` and updated test cases accordingly.
### 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?
### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))
### Description
- Refactor to remove dead features or features already enabled by default
- Remove any checks of cluster version < V21 that are not dependent on persistent storage.
----
#### AI description (iteration 1)
#### PR Classification
Code cleanup
#### PR Summary
This pull request removes dead feature flags and related code from the Pgmongo codebase.
- Removed the `OptimizeIndexExpressionsForDollarIn` function and related comments from `src/opclass/index_support.c`.
- Simplified the `ProcessLookupCoreWithLet` function in `src/aggregation/bson_aggregation_nested_pipeline.c` by removing conditional logic based on cluster version.
- Updated test cases in `src/test/regress/expected/conflicting_indexes.out` to reflect the removal of extended index filters and unsupported expressions in partial indexes.
### 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.
### 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, 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
Implement for stage redact
Related work items: #1798586
### 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)
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))
Aggregation performance pipeline optimization for $lookup and $unwind stage combination on same fields.
### Description
1. Optimize $lookup and $unwind stage combination on same field and lookup options are simple `localField` and `foreignField`
2. Delete dead code for $lookup
----
#### AI description (iteration 1)
#### PR Classification
Code cleanup and optimization.
#### PR Summary
This pull request improves the combination of `$lookup` and `$unwind` aggregation stages by removing redundant and complex code, simplifying the logic, and optimizing performance.
- Removed the `ProcessLookupCore` function and its associated logic from `bson_aggregation_nested_pipeline.c`.
- Removed the `UnwindWalkerContext` struct and related functions for optimizing `$unwind` with `ARRAY_AGG` from `bson_aggregation_nested_pipeline.c`.
### 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?
Yes
### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))
### Description
The Gateway does a convoluted processing for maxTimeMS including having a second connection pool and creating transaction wrappers.
Instead, this is simpler if this is moved into the backend and let the backend set custom timeouts directly.
This part just codes up the backend piece and puts it behind a GUC.
The Gateway changes will be made separately.
----
#### AI description (iteration 1)
#### PR Classification
Code improvement
#### PR Summary
This pull request improves command timeout handling by moving common command timeouts to the backend.
- Added new test files `isolation-command_timeout.out` and `isolation-command_timeout.spec` to validate command timeout scenarios.
- Modified `bson_aggregation_pipeline.c` to remove the `TryHandleSimplifyAggregationRequest` function.
- Updated function signatures in `bson_aggregation_pipeline.h` to include `setStatementTimeout` parameter.
- Adjusted `documents_planner.c` to handle the new `setStatementTimeout` parameter in various query generation functions.
### 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
To enable top level query operators working in schema validation.
----
#### AI description (iteration 1)
#### PR Classification
New feature
#### PR Summary
This pull request introduces support for the `$jsonSchema` query operator for schema validation.
- Added handling for `QUERY_OPERATOR_JSONSCHEMA` in `query_operator.c` and `mongo_query_operator.c`.
- Implemented `GetExpressionEvalStateForBsonInput` in `bson_expr_eval.c`.
- Added `BsonJsonSchemaFunctionId` and related OID cache in `metadata_cache.c`.
- Modified `PrepareForSchemaValidation` in `schema_validation.c` to use the new evaluation state function.
### 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
Split up GUCs by intent:
- Testing GUCs - only for backend or test infra
- System GUCs - configuration of the system as a whole
- Background GUCs - configuration for background jobs
- Feature flag GUCs - GUCs that are transient and we should track enabling and removing them
----
#### AI description (iteration 1)
#### PR Classification
Code cleanup
#### PR Summary
This pull request refactors the codebase by splitting up GUC (Grand Unified Configuration) files based on their intent, improving modularity and maintainability.
- Refactored `documentdb_init.c` to delegate GUC initialization to specific functions.
- Added new files `feature_flag_configs.c`, `system_configs.c`, `background_job_configs.c`, and `testing_configs.c` for modular GUC initialization.
- Updated `config_initialization.h` to declare new initialization functions.
- Adjusted related configurations in `documentdb_distributed_init.c` and test files to align with the new structure.
### 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 source files not pertinent to OSS out of OSS
----
#### AI description (iteration 1)
#### PR Classification
Code cleanup
#### PR Summary
This pull request moves source files not pertinent to OSS out of the OSS directory and includes some code refactoring.
- Moved `rum_custom_join_scan.c` and `external_configs.c` from `pg_documentdb` to `pg_helio_api`.
- Added `IsValidScanPath` function and refactored path validation in `custom_scan_continuation.c`.
- Introduced `TryOptimizePathForBitmapAnd` function in `api_hooks.c` and updated related hooks.
- Added new external configuration variables in `documentdb_init.c`.
- Removed `RegisterRumJoinScanNodes` from `pg_documentdb` and added it to `pgmongo` and `pg_helio_api`.
### 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?
### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))
### Description
Move DocumentDB to schema version 0. To do this version checks now need to handle internal and external versions being different.
Tackle this in version_utils.c
----
#### AI description (iteration 1)
#### PR Classification
New feature
#### PR Summary
This pull request adds support for DocumentDB on version 0.
- Modified `cluster_operations.c` to use `DocDB_V0` for version checks.
- Updated `version_utils.h` and `version_utils.c` to define and use `MajorVersion` enum for version handling.
- Adjusted various files in the `aggregation` directory to use `DocDB_V0` for version checks.
- Updated `create_indexes.c` to use `DocDB_V0` for version checks.
### 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
Start porting schemas for documentdb api.
Introducing API_SCHEMA_NAME_V2, API_SCHEMA_INTERNAL_NAME_V2, API_CATALOG_SCHEMA_NAME_V2
----
#### AI description (iteration 1)
#### PR Classification
Porting type/operator/schema into documentdb.
#### PR Summary
This pull request ports various types, operators, and schemas into documentdb as part of an ongoing effort.
- `pg_documentdb/sql/documentdb--0.24-0.sql`: Created multiple schemas and included various SQL files for query functions, operators, and metadata.
- `pg_documentdb/sql/operators/bson_dollar_operators--0.16-0.sql`: Updated operator definitions to use `__API_SCHEMA_INTERNAL_V2__`.
- `pgmongo/sql/operators/bson_dollar_negation_operators--1.15-1.sql` and `pg_documentdb/sql/operators/bson_dollar_negation_operators--0.16-0.sql`: Changed operator definitions to use `__API_SCHEMA_INTERNAL_V2__`.
- `Makefile.cflags`: Added checks for new schema variables `API_SCHEMA_NAME_V2`, `API_SCHEMA_INTERNAL_NAME_V2`, and `API_CATALOG_SCHEMA_NAME_V2`.
- `pg_documentdb/sql/schema/unique_shard_path_operator_class--0.24-0.sql`: Updated operator class definitions to use `__API_SCHEMA_INTERNAL_V2__`.
### 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
Start porting schemas for SQL in documentdb_core.
Maintain back-compat by introducing CORE_SCHEMA_v2 to handle cases where the existing logic already depends on there being 2 core schemas
----
#### AI description (iteration 1)
#### PR Classification
Code refactoring to port schemas into `documentdb_core`.
#### PR Summary
This pull request refactors the code to port BSON type definitions and related functions into `documentdb_core`.
- `pg_helio_core/sql/types/bson--1.10-0.sql`: Replaced BSON type definitions with an include directive.
- Added `pg_documentdb_core/sql/types/bson--0.24-0.sql` and `pg_documentdb_core/sql/types/bson_typanalyze--0.24-0.sql` for BSON type and analysis functions.
- `pg_documentdb_core/sql/documentdb_core--0.24-0.sql`: Created `documentdb_core` schema and included BSON type definitions.
- Updated Makefiles (`Makefile.cflags`, `pg_helio_api/Makefile`, `pg_helio_core/Makefile`, `internal/pg_helio_distributed/Makefile`) to include new schema definitions.
- Updated `postgresql.conf` files to preload `pg_documentdb_core`.
### Does this PR have any customer impact?
Yes
### 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?
Yes
### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))
### Description
Improve performance for a point read set up for unsharded collections.
In the scenario where we have a point read in a local unsharded collection with colocation, we can bypass a lot of the planner and go directly to the PK index. Use this to simplify the planner.
With this change, point reads on YCSB are able to hit ~16k on Marlin and ~17.5-18k on flex
----
#### AI description (iteration 1)
#### PR Classification
New feature
#### PR Summary
Introduces a custom planner for point read operations to optimize query performance.
- Added `documents_custom_planner.c` to implement the custom point read planner.
- Updated `aggregation_commands.c` to handle the new point read cursor type.
- Modified `planner.c` to integrate the custom point read planner and expand aggregation functions.
### 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))
### Description
Remove helio references from documentdb
Remove helio references from documentdb_distributed
----
#### AI description (iteration 1)
#### PR Classification
Code cleanup
#### PR Summary
This pull request removes references to "helio" and replaces them with "documentdb" in the sources of `documentdb` and `documentdb_distributed`.
- `metadata_cache.h` and `metadata_cache.c`: Replaced "Helio" with "DocumentDB" in variable names and function names.
- `pgmongo.c`: Updated include statements and function calls to use "documentdb" instead of "helio".
- `planner.c`: Updated planner function and related calls to use "DocumentDBApiPlanner".
- Moved several header files from `helio_*` to `documentdb_*` naming convention without code changes.
- `commands_common.c` and `create_indexes.c`: Updated function calls and variable names to use "DocumentDB" instead of "Helio".
### 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?
### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))
### Description
- Redo GUCs for helio -> documentdb preserving back-compat for the service.
- Move Docdb version to 1.24 -> 0.24
----
#### AI description (iteration 1)
#### PR Classification
API change
#### PR Summary
This pull request updates the prefix for all GUCs (Grand Unified Configuration) to a neutral prefix.
- `documentdb_init.c`: Changed GUCs from "helio_api" to a dynamic prefix using `psprintf`.
- `documentdb_distributed_init.c` and `documentdb_distributed.c`: Updated GUCs to use a dynamic prefix.
- `pg_documentdb.c`, `pg_helio_api.c`, and `pgmongo.c`: Modified initialization functions to pass the new GUC prefix.
- `helio_api_init.h` and `helio_distributed_init.h`: Updated function signatures to include the new GUC prefix parameter.
- Updated control files to reflect the new version `0.24-0`.
### 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))
- Push Aggregation queries directly to shard if the collection is unsharded in a single node and pipeline stages refer only 1 collection
### Description
Push Aggregation queries directly to shard if the collection is unsharded in a single node and pipeline stages refer only 1 collection
----
#### AI description (iteration 1)
#### PR Classification
Performance improvement
#### PR Summary
This pull request optimizes the aggregation pipeline by pushing aggregates directly to shards for unsharded tables in a single node setup.
- Added tests in `bson_aggregation_pipeline_tests.out` to verify the new optimization for unsharded collections.
- Updated `bson_aggregation_pipeline_tests.out` in both `pg_helio_distributed` and `helio_compat` to include new test cases and EXPLAIN plans demonstrating the performance improvements.
### 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))
### Description
Remove helio from file name
Remove helio references from source content except schema reference
Start local documentdb server with the documentdb extension
Regression tests using the documentdb extension
----
#### AI description (iteration 1)
#### PR Classification
Code cleanup
#### PR Summary
This pull request removes references to "helio" from the `documentdb_core` source code.
- `scripts/utils.sh`: Renamed variables from `preloadExtensions` to `preloadLibraries`.
- `pg_documentdb_core/include/utils/error_utils.h`: Updated function and macro names to replace "Helio" with "DocumentDB".
- `pg_documentdb_core/include/io/helio_bson_core.h` and `pg_documentdb_core/include/query/helio_bson_compare.h`: Moved to `pg_documentdb_core/include/io/bson_core.h` and `pg_documentdb_core/include/query/bson_compare.h`.
- `pg_documentdb_core/src/collation/collation.c` and `pg_documentdb_core/src/io/pgbson.c`: Replaced error codes and messages to use "DocumentDB" instead of "Helio".
- `scripts/validate_helio_extension_state.sh`: Added exceptions for certain files to skip validation for "helio" references.
### 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] remove dependencies on helio errors
### 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] remove mongo_data references
----
#### AI description (iteration 1)
#### PR Classification
Code cleanup
#### PR Summary
This pull request removes references to `mongo_data` and replaces them with `documentdb_data` across the codebase.
- `collection.h`: Updated constants and macros to use `DOCUMENTDB` instead of `MONGO`.
- `drop_indexes.c`, `create_indexes.c`, `insert.c`: Replaced `MONGO_DATA` table and index format strings with `DOCUMENTDB_DATA`.
- `planner.c`, `bson_aggregation_output_pipeline.c`, `bson_aggregation_pipeline.c`: Updated attribute number constants and variable names.
- `index.h`: Changed index name format prefixes from `MONGO_DATA` to `DOCUMENTDB_DATA`.
- `shard_colocation.c`: Adjusted table prefix strings and comments to reflect the new naming convention.
### Does this PR have any customer impact?
Yes
### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
Bugfix
### 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?
### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))
### Description
- Cluster Data was not replicated fully on add node (upgrades would fail)
- Checks for index wasn't handled in add-node scenarios. (Create/Drop indexes would fail)
- Get versions on the GW on MX of the added node reutrns NullRef - fix these.
----
#### AI description (iteration 1)
#### PR Classification
Bug fix for add-node scenarios.
#### PR Summary
This pull request addresses issues related to ensuring metadata tables are properly replicated during add-node operations.
- `distributed_hooks.c`: Refactored `EnsureMetadataTableReplicatedCore` to return a boolean and added `ExecuteMetadataChecksForReferenceTables`.
- `create_indexes_background.c`: Added checks to ensure metadata tables are replicated before starting index creation.
- `cluster_operations.c`: Ensured `cluster_data` table is replicated on all nodes during cluster setup.
- `api_hooks.c` and `api_hooks.h`: Modified `EnsureMetadataTableReplicated` to return a boolean indicating if replication occurred.
- `ExtensionVersionExtensions.cs`: Added null checks for version strings before writing them.
### 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 source files under new directory.
----
#### AI description (iteration 1)
#### PR Classification
Code reorganization
#### PR Summary
This pull request moves the `helio_api` and `helio_distributed` sources under the `documentdb` directory, updating references and initialization logic accordingly.
- Added `pg_documentdb.c` for initializing the `pg_documentdb` extension.
- Added `documentdb_distributed.c` for initializing the `pg_documentdb_distributed` extension.
- Updated `validate_helio_extension_state.sh` to include new checks for `documentdb`.
- Moved `helio_api_extension_version.c` to `documentdb_extension_version.c` without code changes.
- Updated various `Makefile` configurations to reflect the new directory structure and dependencies.
### 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)
Not yet
### 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
Initial setup for documentdb extensions.
Create Makefiles and set up build scripts around documentdb.
This does not yet touch the actual code or make anything deployable.
----
#### AI description (iteration 1)
#### PR Classification
Initial setup for DocumentDB integration.
#### PR Summary
This pull request sets up the initial structure and configuration for DocumentDB integration.
- Added `documentdb_errors.h` for defining DocumentDB-specific error codes.
- Created `Makefile` for `pg_documentdb`, `pg_documentdb_core`, and `pg_documentdb_distributed` to handle build configurations.
- Updated `validate_helio_extension_state.sh` and `validate_headers.sh` scripts to include checks for DocumentDB.
- Modified `bson_aggregation_nested_pipeline.c`, `bson_aggregation_vector_search.c`, and other source files to replace references from Helio to DocumentDB.
- Added control files for `pg_documentdb`, `pg_documentdb_core`, and `pg_documentdb_distributed` extensions.