13 Commits
Author SHA1 Message Date
Siwen Tang be11798bef Merged PR 1778507: [Refector] Update to match coding standards - part 5
### 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
draft

update error msg

----
#### AI description  (iteration 1)
#### PR Classification
This is a code cleanup and bug‑fix pull request that standardizes and clarifies error messages and log details across multiple modules.

#### PR Summary
The changes improve the consistency, clarity, and accuracy of user‑facing messages and logging throughout the code base. Key changes include:
- In files under directories such as `oss/internal/pg_documentdb_distributed/src/test/regress/expected/` and `pgmongo/src/test/docdb_compat/expected/`, error messages for geospatial query operators (e.g. geoNear, $center, $within) and aggregation stage operators have been rewritten for clarity (e.g. replacing vague “Too many geoNear expressions” with “Excessive number of geoNear query expressions” and clarifying numeric parameter validations).
- Several operators’ messages (e.g. `$cond`, `$not`, `$abs`, `$floor`, `$divide`, `$log`, etc.) have been updated to state exactly how many arguments are required, using
<!-- GitOpsUserAgent=GitOps.Apps.Server.pullrequestcopilot -->
2025-08-25 11:39:17 +08:00
Jia Hu 7db51ff43b Merged PR 1777927: [Refector] Update to match coding standards - part 2
### Does this PR have any customer impact?
Yes
### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
similarity issue
### 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

----
#### AI description  (iteration 1)
#### PR Classification
This pull request is a code cleanup aimed at standardizing and clarifying error and diagnostic messages throughout the codebase.

#### PR Summary
The changes update error messages and logging across many modules (aggregation, query, update, index creation, collation, etc.) to use clearer, more precise, and consistent language.
- **Aggregation Operators:** Many files in the aggregation code (e.g. in `bson_aggregation_*` and related operator implementations) now report errors such as division by zero, invalid inputs, and argument count in a formal and uniform manner.
- **Index & Projection Validation
<!-- GitOpsUserAgent=GitOps.Apps.Server.pullrequestcopilot -->
2025-08-25 11:39:17 +08:00
Cornelius Boateng f983efd1da Merged PR 1683401: [engine][let] Support for update
### 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

### ChangeLog (Refer [Template](../oss/CHANGELOG.md))

### Description
Support let and `$$NOW` variables with update queries.

The values of the variables can be accessed in the query `q` with  `$expr` and 'u' with an aggregation pipeline.
Example:

```
{
      update: <collection>,
      updates: [
            {
                q: {$expr: {$eq: ["$_id", "$$varRef"]}},
                u: [{$set: {"a": "$$NOW"}}],
                multi: false,  // updateOne
            }
      ],
      let: {"varRef": 1},
      ...
}
```

We parse the let value (together with the time system variables - $$NOW) and propagate it through the aggregation and variable contexts.

To enable feature, turn on the `EnableVariablesSupportForWriteCommands` GUC.

----
#### AI description  (iteration 1)
#### PR Classification
This PR implements a new feature by adding support for the "let" variable specification in update commands.

#### PR Summary
The changes integrate "let" support into update operations, allowing dynamic variable specifications to be applied during update candidate selection, serialization, and execution. This enhancement improves the flexibility and expressiveness of update queries in the engine.
- In `src/commands/update.c`, the code now parses and applies a new `variableSpec` (under the "let" field) when building update queries and managing SQL arguments.
- In `include/infrastructure/documentdb_plan_cache.h`, new plan cache macros are added to account for update candidates using let and collation.
- In `include/commands/update.h`, the `UpdateOneParams` structure is updated to include the `variableSpec` parameter.
- In `src/commands/delete.c`, references to the unsupported "let" field in delete commands are removed.
<!-- GitOpsUserAgent=GitOps.Apps.Server.pullrequestcopilot -->

Related work items: #3423115, #3613875
2025-07-23 15:56:08 +08:00
Cornelius Boateng 19ccc295bf Merged PR 1686340: [engine][let] Support for deleteOne on sharded collections with only _id filter
### 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

### ChangeLog (Refer [Template](../oss/CHANGELOG.md))

### Description

`deleteOne` requires `_id` or shard key value filter. If only `_id` is used, we query for the minimum shard key value and use it.
The querying for that shard key must be able to use the `variableSpec`.

----
#### AI description  (iteration 1)
#### PR Classification
API change to enable proper handling of deleteOne commands on sharded collections using only an _id filter by incorporating variable specification support.

#### PR Summary
This pull request enhances deleteOne functionality by integrating a variableSpec (let variable) into query construction for sharded collections, ensuring that _id-only filters are handled correctly. The changes update core command functions, test expectations, and configuration flags to support the new behavior.
- **`commands_common.c`**: Revised the `FindShardKeyValueForDocumentId` function to accept a new variableSpec parameter and conditionally modify the query.
- **`delete.c` and `update.c`**: Updated deletion and update operations to process the variableSpec for write commands.
- **Test and Configuration Files**: Renamed and updated GUC flags (from enableLet... to enableVariablesAndCollationSupportForQueryMatch) and adjusted expected outputs to reflect the new deleteOne behavior.
<!-- GitOpsUserAgent=GitOps.Apps.Server.pullrequestcopilot -->
2025-06-13 15:13:47 +08:00
Jinrui Zhang 356361bceb Merged PR 1628037: Add string case support for '$toDate' operator
### Does this PR have any customer impact?
Yes, by this PR, $toDate could process string case

### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
Enhancement for exsiting operator

### 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?
N/A

### ChangeLog (Refer [Template](../oss/CHANGELOG.md))
Add string case support for '$toDate' operator

### Description
Before this PR, `$toDate` could not parse a string to datetime. With this PR, we leverage the ability of `$dateFromString` to finish the support of string case for `$toDate` operator

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

#### PR Summary
This pull request adds support for string case conversion in the `$toDate` operator.
- Added `StringToDateWithDefaultFormat` function in `bson_expression_date_operators.c` to handle string to date conversion.
- Updated `ProcessDollarToDate` in `bson_expression_type_operators.c` to utilize the new string conversion function.
- Added tests for string case conversion in `$toDate` operator in `bson_aggregation_type_operators_tests.sql`.
- Updated documentation and release notes to reflect the new feature.
<!-- GitOpsUserAgent=GitOps.Apps.Server.pullrequestcopilot -->
2025-05-09 14:08:53 +08:00
Xing Fan 399e01d954 Merged PR 1539417: [Operator] $toUUID in Mongo 8.0
### 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 $toUUID operator

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

#### PR Summary
This pull request introduces the `$toUUID` operator for MongoDB 8.0, enabling conversion of strings to UUIDs.
- Added `ProcessDollarToUUID` function in `bson_expression_type_operators.c` to handle the conversion logic.
- Updated `bson_expression_operators.h` to declare new parsing and handling functions for `$toUUID`.
- Included new test cases in `bson_aggregation_type_operators_tests.sql` and `bson_aggregation_type_operators_tests.out` to validate the `$toUUID` functionality.
- Modified `feature_counter.h` and `feature_counter.c` to include the new `$toUUID` feature in the feature count and mapping.
2025-03-26 12:19:42 +08:00
Cornelius Boateng 746cd8cd64 Merged PR 1588377: [engine][collation][1/n] Collation Support for Aggregation
### 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

### ChangeLog (Refer [Template](../oss/CHANGELOG.md))

### Description
Support collation for filter with `$expr` and comparison operators (`$eq, $ne, $lt, $lte, $gt, $gte)`  in the more performant aggregation framework.

Future items:
Support `collation` in aggregation with `$project`, `$project_find`, `redact`, and collation support by array operators such as `$in`, `$filter`, set operators such as `$setEquals`, `$setIntersection` etc

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

#### PR Summary
This pull request introduces collation support for aggregation operators in the new aggregation framework.
- `bson_expression_comparison_operators.c`: Enhanced comparison operators to handle collation.
- `bson_dollar_operators.c`: Updated to include collation string handling in expression state.
- Added new test cases in `bson_dollar_ops_collation_runtime_tests.sql` and `bson_dollar_ops_collation_runtime_tests.out` to validate collation functionality.
<!-- GitOpsUserAgent=GitOps.Apps.Server.pullrequestcopilot -->

Related work items: #3914009
2025-03-18 21:57:32 -07:00
Cornelius Boateng b0289c3bf3 Merged PR 1518085: [engine] $$NOW in Aggregate and Find with Cursor Support
### 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
2025-02-13 17:09:16 -08:00
Shuai Tian e3dc6c889e Merged PR 1404676: stage implementation: redact
### 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
2025-01-15 07:48:41 +00:00
Jia Hu 55f6fa3840 Merged PR 1485956: [schema validation] support schema rule included top level operator
### 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.
2025-01-15 07:48:41 +00:00
Zinan Ren 8e7bd960bf Merged PR 1540262: [OSS] Remove helio references from sources of documentdb_core
### 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.
2025-01-15 07:48:40 +00:00
Shuai Tian 19f20b4efb Merged PR 1540255: [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 dependencies on helio errors
2025-01-15 07:48:40 +00:00
Vinod Sridharan 3f9a507562 Merged PR 1539950: [OSS] Move helio_api and helio_distributed sources under documentdb
### 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.
2025-01-15 07:48:39 +00:00