Commit Graph
398 Commits
Author SHA1 Message Date
Deepak Bisht febf50e8aa Merged PR 1473095: [OSS] Test migration [23 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

----
#### 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.
2024-10-03 10:48:48 +03:00
Cornelius Boateng 80077a901c Merged PR 1459965: [Perf] String Aggregation Ops
### 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
2024-10-03 10:48:48 +03:00
Vinod Sridharan c0d703526a Merged PR 1473730: [OSS] Add conversion helper function from helio error codes to mongo error codes
### Does this PR have any customer impact?
No

### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
Features

### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes)
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
Add code generated helper function to convert helio errors to mongo error codes.

----
#### AI description  (iteration 1)
#### PR Classification
New feature

#### PR Summary
This pull request introduces a new helper function to convert Helio error codes to Mongo error codes.
- Added `helio_errors.c` to implement the conversion logic.
- Updated `generate_error_values.sh` to generate the new conversion file.
- Modified `Makefile` to include the new conversion file in the build process.
- Updated `helio_errors.h` to declare the new conversion function.
2024-10-03 10:48:48 +03:00
Vinod Sridharan cdc00f176d Merged PR 1472614: [AddNode] Fix up add node for distribution
### 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.
2024-10-03 10:48:48 +03:00
Parag Jain 07a4125ae5 Merged PR 1469364: [Perf] Delete directly from shard in delete one if available
### 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.
2024-10-03 10:48:48 +03:00
Cornelius Boateng d5954f7381 Merged PR 1470292: [Perf] Date Aggregation Ops
### 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

Migrate date aggregation operators to new aggregation framework.

----
#### AI description  (iteration 1)
#### PR Classification
Performance improvement

#### PR Summary
This pull request migrates date aggregation operators to a new framework to enhance performance.
- `src/operators/bson_expression_date_operators.c`: Refactored functions to separate parsing and execution of date part operators, added new helper functions for handling pre-parsed expressions.
- Updated function names to reflect the new parsing and execution separation.
- Improved handling of timezone application and constant expression evaluation.

Related work items: #3458680
2024-10-03 10:48:48 +03:00
Ayush Saluja d853734052 Merged PR 1460382: empty collection name check
### 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
2024-10-03 10:48:48 +03:00
Deepak Bisht a4b0c5bc44 Merged PR 1466193: OSS test migration Part 4 [9 tests]
### 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.
2024-10-03 10:48:48 +03:00
Parag Jain 1367513491 Merged PR 1470087: [OSS] Test Cleanup removing invalid schemas from test
### 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`.
2024-10-03 10:48:48 +03:00
Vinod Sridharan 472d3182a5 Merged PR 1469479: [OSS] Bugfixes from OSS and Incidents
### Does this PR have any customer impact?
No

### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
Bugfix

### 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?

### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))

### Description
- Invalidate Collection cache trigger was missing in OSS
- Explain should show IXScan if the index had object_id
- ErrCode 16020 should be Location16020 and not EXPRESSIONTAKESEXACTLYNARGS
- row_get_bson should be prefixed with schema.

----
#### AI description  (iteration 1)
#### PR Classification
Bug fix

#### PR Summary
This pull request addresses several bugs identified from OSS and incidents, including updates to SQL functions, error codes, and triggers.
- Added new SQL functions and triggers in `collection_metadata_functions--1.23-0.sql` and updated `collection_metadata_functions--latest.sql`.
- Modified `PostgresExplainHelper.cs` to refine the condition for reporting `COLLSCAN`.
- Updated error codes in `helio_errors.h`, `mongoerrors.csv`, and `helio_codes.txt`.
- Adjusted SQL queries in `users.c` and `create_indexes_background.c` to use `CoreSchemaName`.
- Added a new trigger in `collection_metadata--1.23-0.sql` and included it in `pg_helio_api--1.22-0--1.23-0.sql` and `pgmongo--1.22-0--1.23-0.sql`.
2024-10-03 10:48:48 +03:00
Cornelius Boateng 3e68960e3c Merged PR 1461259: [Perf] Objects Aggregation 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

$mergeObjects

----
#### AI description  (iteration 1)
#### PR Classification
Performance improvement for object aggregation operators.

#### PR Summary
Refactors and optimizes the handling of `$mergeObjects` aggregation operator to improve performance.
- `src/operators/bson_expression_object_operators.c`: Refactored `HandleDollarMergeObjects` to `ParseDollarMergeObjects` and `HandlePreParsedDollarMergeObjects`, optimizing argument parsing and result processing.
- `include/operators/bson_expression_operators.h`: Updated function declarations to reflect the new parsing and handling methods.
- `src/operators/bson_expression.c`: Updated the operator expressions array to use the new parsing and handling functions for `$mergeObjects`.
2024-09-26 17:53:12 +03:00
Deepak Bisht 3eb64de267 Merged PR 1467661: [Cleanup][backend] Remove legacy errors and all referrences completely
### 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.
2024-09-26 17:53:12 +03:00
Parag Jain e58c52b6f7 Merged PR 1466244: Enable $out stage GUC
### 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.
2024-09-26 17:53:12 +03:00
Ujjwal Agrawal bc57b427a4 Merged PR 1462597: Add apiStrict and apiDeprecationErrors to ignored spec fields
### 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 do not support apiVersion, so apiStrict and apiDeprecationErrors can be ignored for now.

----
#### AI description  (iteration 1)
#### PR Classification
Code update to support or ignore specific API parameters.

#### PR Summary
This pull request updates the code to include `apiStrict` and `apiDeprecationErrors` in the list of ignored specification fields, addressing the requirements of the linked work item.
- `commands_common.c`: Added `apiStrict` and `apiDeprecationErrors` to the `IgnoredCommonSpecFields` array.

Related work items: #3463178
2024-09-26 17:53:12 +03:00
Vinod Sridharan a0ef11359c Merged PR 1463595: [AddNode|Rebalance] Part 1: Fix up schema to support rebalancing
### 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.
2024-09-26 17:53:12 +03:00
Lusen Dong 2126f6688d Merged PR 1461377: Update comprehensive parse jstest
### 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 jstest passrate

----
#### AI description  (iteration 1)
#### PR Classification
Bug fix and enhancement for the `$derivative` stage aggregation operator.

#### PR Summary
This pull request addresses a bug and enhances the `$derivative` stage aggregation operator by handling `BSON_TYPE_DATE_TIME` and preventing division by zero errors.
- `bson_aggregation_statistics.c`: Added handling for `BSON_TYPE_DATE_TIME` in `yValueElement` and checks to prevent division by zero.
- `60_postgres_10260.csv` and `70_postgres_10260.csv`: Updated test results for `comprehensive_parse.js` from Fail to Pass.

Related work items: #2151582
2024-09-26 17:53:12 +03:00
Deepak Bisht ec6a642c49 Merged PR 1458010: update comments for setwindowfields JStests
### Does this PR have any customer impact?
no

### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
Comments

### 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
update comments for setwindowfields JStests

----
#### AI description  (iteration 1)
#### PR Classification
Documentation update for JStests related to `setWindowFields`.

#### PR Summary
This pull request updates comments and error messages for JStests related to `setWindowFields` to provide more accurate descriptions of the failures.
- `/gateway/managed/Tests.Integration.Shell.Postgres/60_postgres_10260.csv`: Updated failure reasons for various `setWindowFields` tests.
- `/oss/pg_helio_api/src/commands/coll_stats.c`: Added validation to ensure `$collStats.count` is an empty object.
- `/oss/mongoerrors.csv`, `/oss/pg_helio_core/include/utils/helio_errors.h`, `/oss/pg_helio_core/include/utils/helio_codes.txt`: Added new error code `Location31170`.
- `/oss/pg_helio_api/src/commands/commands_common.c`: Added `apiStrict` to ignored common spec fields.
2024-09-26 17:53:12 +03:00
Parag Jain 178bd92c38 Merged PR 1462509: [OSS] Test Migration PART-3 [22 Test]
### 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.
2024-09-26 17:53:12 +03:00
Manish Gaur c28a4841da Merged PR 1462717: version update to start 1.22 release
### 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/`.
2024-09-19 20:36:13 +03:00
Parag Jain 1b85d0ac80 Merged PR 1461213: [OSS] Test Migration PART-2 [11 Test]
### 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`.
2024-09-19 20:36:13 +03:00
Vinod Sridharan 98a3dbe1fc Merged PR 1462312: Cleanup for internal errors from prod
### Does this PR have any customer impact?
No

### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
Bugfixes
### 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
Cleanup for internal errors

----
#### AI description  (iteration 1)
#### PR Classification
Code cleanup to handle internal errors more effectively in production.

#### PR Summary
This pull request enhances error handling by adding specific checks for out-of-memory errors and refining existing error messages.
- `src/commands/diagnostic_commands_common.c`: Added handling for out-of-memory errors and refined error checks for recovery conflicts.
- `PostgresClient.cs`: Added specific handling for `OutOfMemoryException`.
- `PostgresMongoResultExtensions.cs`: Added new error messages for vector dimension constraints and refined existing error messages.
2024-09-19 20:36:13 +03:00
Deepak Bisht b6e3729219 Merged PR 1461546: Geospatial Internal error fix, Self-Intersection found in Segmentize query
### 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))
na

### Description
fix TopologyException internal error while segmentizing the query for better index scans

----
#### AI description  (iteration 1)
#### PR Classification
Bug fix for handling self-intersection errors in geospatial segmentize queries.

#### PR Summary
This pull request addresses an internal error caused by self-intersections in geospatial segmentize queries by incorporating the `ST_MAKEVALID` function.
- `/oss/pg_helio_api/src/opclass/bson_gist_geospatial.c`: Updated `BaseGeoSubdivideQuery` to use `ST_MAKEVALID` with `ST_SEGMENTIZE` to ensure valid geometries.
- `/pgmongo/src/test/regress/expected/geospatial_extract_2d_geometries.out` and `/pgmongo/src/test/regress/sql/geospatial_extract_2d_geometries.sql`: Added tests to validate the fix, demonstrating the use of `ST_MAKEVALID` to correct invalid geometries created by `ST_SEGMENTIZE`.

Related work items: #3494552
2024-09-19 20:36:13 +03:00
Parag Jain 9296b0e0cf Merged PR 1459551: [OSS] Test Migration PART-1 [28 Test]
### 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
2024-09-19 20:36:13 +03:00
Deepak Bisht e3dc051d47 Merged PR 1460123: min max window operator in setwindowFields
### 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))
min and max supported in $setwindowFields

### Description
Use the existing bsonmax and bsonmin aggregate functions for window operations in setwindowfields

----
#### AI description  (iteration 1)
#### PR Classification
New feature: Added min and max window operators in `setWindowFields`.

#### PR Summary
This pull request introduces the `$min` and `$max` window operators to the `setWindowFields` aggregation stage.
- `oss/pg_helio_api/src/aggregation/bson_aggregation_window_operators.c`: Added handlers for `$min` and `$max` window operators.
- `pgmongo/src/test/regress/sql/bson_aggregation_pipeline_stage_setWindowFields.sql`: Added tests for `$min` and `$max` window operators.
- `pgmongo/src/test/regress/expected/bson_aggregation_pipeline_stage_setWindowFields.out`: Updated expected output for new tests.
- `gateway/managed/Tests.Integration.Shell.Postgres/60_postgres_10260.csv`: Updated test results to reflect support for new window operators.
2024-09-19 20:36:13 +03:00
Ujjwal Agrawal dc157bd631 Merged PR 1446886: $first(N) & $last(N) implementation for $setWindowFields stage
### 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
2024-09-19 20:36:13 +03:00
Amit Prabhudesai 06bb0a2e36 Merged PR 1460321: Enable background index builds by default
### Does this PR have any customer impact?
Yes

### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
Default configuration change

### 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 new configs

### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))

### Description
Enable background index builds by default

----
#### AI description  (iteration 1)
#### PR Classification
Configuration change to enable background index builds by default.

#### PR Summary
This pull request enables background index builds by default to improve performance and reduce downtime during index creation.
- `TenantConfigurationBase.cs`: Changed `EnableIndexBuildBackground` default value to `true`.
- `helio_api_init.c`: Changed `DEFAULT_ENABLE_INDEX_BUILD_BACKGROUND` default value to `true`.
2024-09-19 20:36:13 +03:00
Jinrui Zhang 55b25d9c55 Merged PR 1423500: Implementation of $fill stage
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`.
2024-09-19 20:36:13 +03:00
Duan Pei✨ f2e84f4881 Merged PR 1456663: [Feature] $maxN/$minN with setWindowFields stage
### 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
New feature: Adds support for `$maxN` and `$minN` operators in the `setWindowFields` stage.

#### PR Summary
This pull request introduces the `$maxN` and `$minN` window aggregation operators, including their syntax validation and handling.
- `oss/pg_helio_api/src/aggregation/bson_aggregation_window_operators.c`: Added functions to handle `$maxN` and `$minN` operators, including syntax validation.
- `pgmongo/src/test/regress/sql/bson_aggregation_pipeline_stage_setWindowFields.sql`: Added tests for `$maxN` and `$minN` operators with various window configurations.
- `pgmongo/src/test/regress/expected/setwindowfields_and_group_compliance.out`: Updated compliance tests to reflect support for `$maxN` and `$minN` in `setWindowFields`.
2024-09-19 20:36:13 +03:00
Parag Jain 98f164e89c Merged PR 1458853: [Cleanup] Merge Legacy Cleanup PR
### 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
Before 1.20 release join condition we were not pushing down to index so in join function itself we use to validate `on` field values and compare target with source. but In 1.20 we have introduced index index push down for join condition where we are using support function for `bson_dollar_merge_join` so we validate on fields values in source projection itself using `bson_dollar_extract_merge_filter`.

So now as part of this PR we are at 1.20+ so removed older code bits which we are not going to use.

this was the PR where we have introduced index pushdown
https://msdata.visualstudio.com/CosmosDB/_git/pgmongo/pullrequest/1425893
2024-09-19 20:36:13 +03:00
Lusen Dong 0ed2fb5e42 Merged PR 1456650: More tests and new log error schema on integral operator
### 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

----
#### AI description  (iteration 1)
#### PR Classification
New feature and code improvement.

#### PR Summary
This pull request implements the `$derivative` stage aggregation operator and refines error handling in the integral operator.
- `bson_aggregation_window_operators.c`: Improved error handling and calculation of time units for the integral operator.
- `bson_aggregation_statistics.c`: Updated error code for internal errors in handling integral and derivative operations.

Related work items: #2151582
2024-09-19 20:36:13 +03:00
Deepak Bisht 91e5f2226f Merged PR 1458099: [Final] [Port Errors] - Move all errors to helio_errors, remove all referrences to mongo_errors.h
### 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.
2024-09-19 20:36:13 +03:00
Jayanta Mondal d0bb21a7ff Merged PR 1457106: [engline] Setting enableCollation to false by default
### 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`.
2024-09-19 20:36:13 +03:00
Gledis Zeneli 6d239e3edc Add [Deb, Ubuntu] x [PG 15, PG 16] Packaging (#58)
Add automated script for extension packaging.
The script enables packaging and testing for all combinations of
`[Debian 12, Debian 11, Ubuntu 24.04, Ubuntu 22.04, Ubuntu 20.04] x [PG
16, PG 15]`
2024-09-19 18:57:15 +03:00
Amit Prabhudesai 8fdb33dc6a Merged PR 1454239: [OSS] Port more errors to oss (M of N)
### 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.
2024-09-12 13:51:02 +03:00
Duan Pei✨ 7fd8660ac4 Merged PR 1363174: [Feature] $maxN/$minN Aggregation Accumulator
### 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:
![image (10).png](https://msdata.visualstudio.com/ba574a88-a171-48e0-8fcb-5fef6d23739c/_apis/git/repositories/501a5e7e-ffdc-4d1e-a5e6-910f73c6eb9a/pullRequests/1363174/attachments/image%20%2810%29.png)

N also can be a expression:
![image (11).png](https://msdata.visualstudio.com/ba574a88-a171-48e0-8fcb-5fef6d23739c/_apis/git/repositories/501a5e7e-ffdc-4d1e-a5e6-910f73c6eb9a/pullRequests/1363174/attachments/image%20%2811%29.png)

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.
2024-09-12 13:51:02 +03:00
Cornelius Boateng 1181330b3b Merged PR 1450898: [Perf] Miscellaneous Aggregation Ops
### Does this PR have any customer impact?

### 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
Migrate `$rand` and `$meta` to the new aggregation framework.
$rand does not need to exploit caching random constant values

----
#### AI description  (iteration 1)
#### PR Classification
Performance improvement for miscellaneous aggregation operations.

#### PR Summary
This pull request optimizes and refactors various aggregation operations to enhance performance.
- Added and reordered function declarations in `include/operators/bson_expression_operators.h` for better organization.
- Implemented `ParseDollarRand` and `HandlePreParsedDollarRand` functions in `src/operators/bson_expression_miscellaneous_operators.c` to handle `$rand` expressions.
- Added `ParseDollarMeta` and `HandlePreParsedDollarMeta` functions in `src/operators/bson_expression_miscellaneous_operators.c` to handle `$meta` expressions.
- Updated `src/operators/bson_expression.c` to integrate new parsing and handling functions for `$rand` and `$meta` expressions.

Related work items: #3458675
2024-09-12 13:51:02 +03:00
Deepak Bisht a30d2cdfbe Merged PR 1455470: Port to new errors in operators, planners, query, schema_validation directories
### 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.
2024-09-12 13:51:02 +03:00
Parag Jain 194a418c6f Merged PR 1455447: [oss] error code cleanup for oss
### 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

#### PR Summary
This pull request focuses on cleaning up error code handling related to MongoDB errors.
- Removed MongoDB-specific error handling from `oss/pg_helio_api/include/utils/mongo_errors.h`.
- Moved MongoDB error handling logic to `oss/pg_helio_core/include/utils/error_utils.h`.
- Updated various source files to include `utils/helio_errors.h` instead of `utils/mongo_errors.h`.
- Modified `scripts/validate_helio_extension_state.sh` to check for MongoDB error codes in additional directories.
2024-09-12 13:51:02 +03:00
Deepak Bisht d964b664e9 Merged PR 1454469: Cleanup - Remove vCore referrence from OSS code
### Does this PR have any customer impact?
no

### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
cleanup

### 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
Cleanup - Remove vCore referrence from OSS code

----
#### AI description  (iteration 1)
#### PR Classification
Code cleanup to remove references to vCore from the OSS code.

#### PR Summary
This pull request removes references to vCore from the OSS codebase and updates error messages accordingly.
- `bson_aggregation_window_operators.c`: Updated error messages to remove vCore version references and replaced them with generic "not supported yet" messages.
- `bson_aggregation_window_operators.c`: Changed error codes for unsupported commands to `ERRCODE_HELIO_COMMANDNOTSUPPORTED`.
- `bson_aggregation_window_operators.c`: Updated comments to replace "vCore specific options" with "helio specific options".
2024-09-12 13:51:02 +03:00
Lusen Dong 4c20fb3e1d Merged PR 1455392: fix memory corruption in $integral window operator
### Does this PR have any customer impact?
No
### 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

fix memory corruption

----
#### AI description  (iteration 1)
#### PR Classification
Bug fix to address memory corruption in the `$integral` window operator.

#### PR Summary
This pull request fixes a memory corruption issue in the `$integral` window operator by modifying how string memory is allocated and managed.
- `oss/pg_helio_api/src/aggregation/bson_aggregation_window_operators.c`: Replaced manual string allocation and copying with `StringInfo` for safer memory handling.

Related work items: #2151586
2024-09-12 13:51:02 +03:00
Xiaochun Liang 4c6baa57bf Merged PR 1425609: Window function support for StdDevPop and StdDevSamp
### 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
New feature: Adds support for window functions `StdDevPop` and `StdDevSamp`.

#### PR Summary
This pull request introduces support for the `StdDevPop` and `StdDevSamp` window functions in the aggregation framework.
- `oss/pg_helio_api/src/aggregation/bson_aggregation_window_operators.c`: Added handlers for `$stdDevPop` and `$stdDevSamp` window aggregation operators.
- `gateway/managed/Tests.Integration.Shell.Postgres/60_postgres_10260.csv` and `70_postgres_10260.csv`: Updated test results to reflect the support for the new window functions.
2024-09-12 13:51:02 +03:00
Parag Jain fb4b29be9e Merged PR 1454613: [OSS] mongo_error header file validation
### 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.
2024-09-12 13:51:02 +03:00
Parag Jain 5e8554b3c6 Merged PR 1454140: [OSS] Port more error codes to OSS
### 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`.
2024-09-12 13:51:02 +03:00
Ayush Saluja 102ab33b99 Merged PR 1452980: Fixup error code for invalid path in findAndModify
### 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

adding check for changing error code

----
#### AI description  (iteration 1)
#### PR Classification
Bug fix to correct the error code returned by the `findAndModify` operation.

#### PR Summary
This pull request addresses the issue where the `findAndModify` operation returns the wrong error code.
- `oss/pg_helio_api/src/update/bson_update_operators_workflow.c`: Changed the error code from `ERRCODE_HELIO_BADVALUE` to `MongoPathNotViable` when a field creation fails.

Related work items: #3463166
2024-09-12 13:51:02 +03:00
Deepak Bisht ccc656e5f0 Merged PR 1454152: Port errors for geospatial, command, index_am folders
### 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`.
2024-09-12 13:51:02 +03:00
Parag Jain 2e0b88d293 Merged PR 1453931: Enabling GUC merge across DB
### 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
Enabling merge across DB
Now we have Citus 12.1.5 in the prod which has the fix to support merge across DB so enabling it.

----
#### AI description  (iteration 1)
#### PR Classification
Configuration change to enable a feature.

#### PR Summary
This pull request enables the merge across databases feature by default.
- `oss/pg_helio_api/src/helio_api_init.c`: Changed `DEFAULT_ENABLE_MERGE_ACROSS_DB` from `false` to `true`.
2024-09-12 13:51:02 +03:00
Lusen Dong a45694828a Merged PR 1416932: [Feature] window operator $integral and $derivative
### Does this PR have any customer impact?
Yes
### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
Feature
### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes)
UDF
### Are you introducing any new config? If yes, do you have tests with and without them being set?
No
### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))

### Description
add a window operator, $integral

----
#### AI description  (iteration 1)
#### PR Classification
New feature: Adds a new window operator `$integral` for aggregation.

#### PR Summary
This pull request introduces the `$integral` window operator to compute integrals using the trapezoidal rule in BSON aggregation.
- Added `BsonIntegralAggState` structure and related functions in `bson_aggregates.c` to handle integral calculations.
- Implemented `HandleDollarIntegralWindowOperator` in `bson_aggregation_window_operators.c` to process the new `$integral` operator.
- Updated SQL UDFs in `group_aggregates_support--latest.sql` and `group_aggregates--latest.sql` to include the new `bson_integral_transition` and `bson_integral_final` functions.
- Added `BsonIntegralAggregateFunctionOid` in `metadata_cache.c` and `metadata_cache.h` for function OID retrieval.
- Exposed `GetDecimal128FromInt64` in `decimal128.c` and `decimal128.h` for converting integers to BSON decimal128 format.

Related work items: #3343290
2024-09-12 13:51:02 +03:00
Deepak Bisht 68f0438c85 Merged PR 1436133: $densify aggregation stage
### 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

![image.png](https://msdata.visualstudio.com/ba574a88-a171-48e0-8fcb-5fef6d23739c/_apis/git/repositories/501a5e7e-ffdc-4d1e-a5e6-910f73c6eb9a/pullRequests/1436133/attachments/image.png)

----
#### 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
2024-09-12 13:51:02 +03:00
Ujjwal Agrawal 213287f350 Merged PR 1408344: $top(N)/$bottom(N) accumulator operators implementation
### 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
2024-09-12 13:51:02 +03:00
Deepak Bisht 82bd3295f7 Merged PR 1452704: Fix IsNan and IsInfinity for decimal128
### 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

Fix IsNan and IsInfinity for decimal128

----
#### AI description  (iteration 1)
#### PR Classification
Bug fix for handling `IsNan` and `IsInfinity` functions for `decimal128` type.

#### PR Summary
This pull request fixes the `IsNan` and `IsInfinity` functions to correctly handle `decimal128` values.
- `oss/pg_helio_core/src/query/bson_compare.c`: Updated `IsBsonValueNaN` and `IsBsonValueInfinity` to use specific checks for `decimal128`.
- `oss/pg_helio_core/src/types/decimal128.c`: Modified `IsDecimal128Infinity` to return the sign of infinity.
- `oss/pg_helio_core/include/types/decimal128.h`: Updated function signature for `IsDecimal128Infinity` to include a boolean for positive infinity.
2024-09-12 13:51:02 +03:00