Commit Graph
17 Commits
Author SHA1 Message Date
Xiaochun Liang 250d7f98af Merged PR 1535636: Support DBRef in upsert case
### 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

This is the PR to fix js error of jstests/core/server1470.js

In upsert case, TraverseQueryDocumentAndProcess skips processing $ref or $id, for example, given sample query:

`db.server1470.update({
    "name": "first",
    "pic": {"$ref": "foo", "$id": ObjectId("4c48d04cd33a5a92628c9af6")}
}, {$set: {x: 1}}, true, true);`

"pic" field is skipped and not inserted in the collection.

Changes includes:
1. Support $ref and $id in upsert case
2. handle error cases

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

#### PR Summary
This pull request adds support for DBRef in upsert operations.
- Modified `bson_query.c` to handle `$ref` and `$id` operators during upsert.
- Updated `query_operator.c` to include error handling for DBRef fields.
- Added new test cases in `commands_update.sql` and `commands_update.out` to validate DBRef upsert functionality.
- Introduced new error codes in `helio_errors.h`, `helio_codes.txt`, and related CSV files for DBRef validation errors.
2025-01-15 07:48:40 +00:00
Deepak Pemmaraju 19abafcc95 Merged PR 1511520: adding a limit of 10 users for dataplane user crud api
### 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 a limit of 10 users for dataplane user crud api

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

#### PR Summary
This pull request enforces a limit of 10 users for the Dataplane user CRUD API.
- `oss/pg_helio_api/src/commands/users.c`: Added logic to check and enforce the maximum user limit before creating a new user.
- `oss/pg_helio_api/src/helio_api_init.c`: Introduced a new configuration variable `helio_api.maxUserLimit` to set the maximum number of users allowed.
- `pgmongo/src/test/regress/sql/user_crud_commands.sql` and `pgmongo/src/test/regress/expected/user_crud_commands.out`: Added tests to verify the user limit enforcement and behavior when the limit is exceeded.

Related work items: #3175767
2024-12-16 11:37:44 +08:00
Ujjwal Agrawal 37681b511b Merged PR 1493190: Update error codes from pg to helio and add missing sql 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

Bug fix to update error codes from Postgres to HelioDB-specific codes. Checking and updating error codes for each command. FerretDB reported bug.

Related work items: #3554201
2024-11-04 17:14:58 +08:00
Shuai Tian f8c366966d Revert "HelioDB Push 2024-10-31" (#76)
Reverts microsoft/heliodb#75, redo the merge instead of squash merge
which discarded the commit history
2024-11-04 14:38:52 +08:00
69edcc3556 HelioDB Push 2024-10-31 (#75)
Co-authored-by: Deepak Pemmaraju <deepakpe@microsoft.com>
Co-authored-by: Cornelius Boateng <cboateng@microsoft.com>
Co-authored-by: Ujjwal Agrawal <uagrawal@microsoft.com>
Co-authored-by: Jia Hu 👻 <jiahu2@microsoft.com>
Co-authored-by: Jayanta Mondal <jmondal@microsoft.com>
Co-authored-by: Vinod Sridharan <visridha@microsoft.com>
2024-10-31 16:09:00 +08:00
Parag Jain f801b9e7a3 Merged PR 1490550: [Bug Fix] $merge bug fix while checking presence of compound index on target collection
### 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
This PR contains 2 fixes
- In $merge `on` field cannot contain duplicate element:    `{ "$merge" :  {"on" : [a,a] }`
- we were missing a case while validating on field against index array.

```
let's say indexSpec :  { "x" : 1, "y" : 1, "z" : 1}
then below cases also expected to be fail as index array has extra element.
 `{ "$merge" :  {"on" : [x,z] }`
 `{ "$merge" :  {"on" : [x,y] }`
```

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

#### PR Summary
Fixes a bug in the `$merge` operation by ensuring proper detection of compound unique indexes and handling duplicate fields.
- `bson_aggregation_output_pipeline.c`: Corrected logic to check for compound unique indexes and added error handling for duplicate fields.
- `bson_aggregation_stage_merge_tests.sql` and related test output files: Added tests to verify the detection of duplicate fields and proper index checking.
- `helio_conversion_codes.c`: Added a new error code for duplicate field detection.
- Updated error code mappings in `mongoerrors.csv`, `helioerrors.csv`, `helio_codes.txt`, and `mongo_codes.csv`.
2024-10-25 09:11:39 +03:00
Vinod Sridharan 9cc8055eff Merged PR 1474463: [OSS] Split error mapping for Helio and wire protocols
### 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 Error map reference into a helio and mongo set of values. This splits error mapping to helio and error for other implementations like mongo wire protocol.

----
#### AI description  (iteration 1)
#### PR Classification
Code cleanup

#### PR Summary
This pull request moves the error map reference to a generated folder, cleaning up the source directory.
- Removed Mongo error code definitions from `oss/pg_helio_core/include/utils/helio_errors.h`.
- Added `oss/pg_helio_core/generated/include/utils/helio_error_conversion.h` with Mongo error code definitions.
- Updated `oss/scripts/generate_error_values.sh` to handle the new generated header file.
- Moved `oss/pg_helio_core/src/utils/helio_errors.c` to `oss/pg_helio_core/generated/src/utils/helio_error_conversion.c`.
- Updated `pgmongo/Makefile` to include the new generated directory in the build process.

----
#### AI description  (iteration 1)
#### PR Classification
Code cleanup

#### PR Summary
This pull request moves the error map reference to a generated folder, separating it from the source directory.
- `oss/pg_helio_core/include/utils/helio_errors.h`: Removed Mongo error code definitions.
- `oss/pg_helio_core/generated/include/utils/helio_error_conversion.h`: Added new file for Mongo error code definitions.
- `oss/scripts/generate_error_values.sh`: Updated script to generate new header and source files for error conversion.
- `pgmongo/Makefile`: Updated include paths to reference the new generated directory.
- Moved `oss/pg_helio_core/src/utils/helio_errors.c` to `oss/pg_helio_core/generated/src/utils/helio_error_conversion.c` without code changes.
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
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
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
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
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
Parag Jain 7740a1f014 Merged PR 1439695: [Feature] $out 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)
No
### Are you introducing any new config? If yes, do you have tests with and without them being set?
No
### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))

### Description
support for $out aggregation stage in aggregation pipeline

what we not support :
1. On Mult coordinator setup source and target can not be same

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

#### PR Summary
This pull request introduces the `$out` aggregation stage to the aggregation pipeline.
- `oss/pg_helio_api/src/aggregation/bson_aggregation_output_pipeline.c`: Added `HandleOut` function to handle the `$out` stage, including parsing, validation, and query mutation for outputting results to a specified collection.

Related work items: #1798580
2024-09-12 13:51:02 +03:00
Vinod Sridharan 3d3298c4b2 Merged PR 1448867: Move to helio errors in helio core
### Does this PR have any customer impact?
No

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

### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes)
No

### Are you introducing any new config? If yes, do you have tests with and without them being set?
No
### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))

### Description
Move to helio error codes in pg-helio-core

Enforce hygiene in helio core

Move to helio errors

----
#### AI description  (iteration 1)
#### PR Classification
Code cleanup

#### PR Summary
This pull request refactors error handling by replacing Mongo-specific error codes with Helio-specific error codes and updates error messages accordingly.
- Added `CheckNoMongoErrorCodes` function in `/scripts/validate_helio_extension_state.sh` to ensure no Mongo-specific error codes are used.
- Updated error codes and messages in `oss/pg_helio_core/src/query/bson_compare.c` to use Helio-specific codes.
- Modified error handling in `oss/pg_helio_core/src/types/pcre_regex.c` to replace Mongo error codes with Helio error codes.
- Replaced Mongo error codes with Helio error codes in `oss/pg_helio_core/src/io/pgbsonsequence.c`.
- Updated error codes in `oss/pg_helio_core/src/types/decimal128.c` to use Helio-specific codes.
2024-09-12 13:51:02 +03:00
Vinod Sridharan 744b8274ab Merged PR 1443261: [Helio Errors] Generate error codes that are PG compatible
### Does this PR have any customer impact?

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

### 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
Generate error codes that are PG compatible
- Code-gen header file for Mongo Errors
- Generate a text file that can be used for other languages.

- In subsequent changes the existing codebase will be updated to consume these errors.

----
#### AI description  (iteration 1)
#### PR Classification
New feature: Generate error codes that are PostgreSQL (PG) compatible.

#### PR Summary
This pull request introduces a new feature to generate error codes that are compatible with PostgreSQL.
- Added `helio_errors.h` with definitions for various Helio error codes and their corresponding MongoDB error codes.
- Created `mongoerrors.csv` to map error names to MongoDB error codes and their ordinal positions.
2024-09-05 18:18:23 +03:00