Commit Graph
43 Commits
Author SHA1 Message Date
Zinan Ren 🐾 1e9746818f Merged PR 1487172: [Vector Search][Embedding Gen Part 1] Refactor update operators and search spec to support non-oss
### Does this PR have any customer impact?
Yes

### 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?
pgmongo.enableEmbeddingGeneration, default is false(feature disabled)

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

### Description
The goal of this feature is enable an inline embedding generation in vCore based on [azure_ai extension]
(https://learn.microsoft.com/en-us/azure/postgresql/flexible-server/generative-ai-azure-openai)

Related design doc [Inline embedding generation in vCore ](https://microsoftapc-my.sharepoint.com/:w:/g/personal/zhli2_microsoft_com/Ea2uDc0c0FBNr-fpoMdHIPUBJiA5yXZ-xRRNWGYEBqZ38Q?e=dQdU7i&ovuser=72f988bf-86f1-41af-91ab-2d7cd011db47%2Crongwa%40microsoft.com&clickparams=eyJBcHBOYW1lIjoiVGVhbXMtRGVza3RvcCIsIkFwcFZlcnNpb24iOiI0OS8yNDAzMTQxNDcxMiIsIkhhc0ZlZGVyYXRlZFVzZXIiOmZhbHNlfQ%3D%3D)
![image.png](https://msdata.visualstudio.com/ba574a88-a171-48e0-8fcb-5fef6d23739c/_apis/git/repositories/501a5e7e-ffdc-4d1e-a5e6-910f73c6eb9a/pullRequests/1339487/attachments/image.png)

- Feature Flag
**pgmongo.enableEmbeddingGeneration**

- Feature counter
**update_operator_vector_gen_embeddings**
**search_vector_gen_embeddings**

- Onboard AOAI resource([Part 3 PR](https://msdata.visualstudio.com/CosmosDB/_git/pgmongo/pullrequest/1478366))
```
SELECT create_distributed_table('azure_ai.settings','key');

SELECT azure_ai.set_setting('azure_openai.endpoint','https://localhost.openai.azure.com');
SELECT azure_ai.set_setting('azure_openai.subscription_key','<api-key-placeholder>');

ALTER SYSTEM SET pgmongo.azureOpenAIEmbeddingDeploymentName = 'text-embedding-ada-002';
SELECT pg_reload_conf();
SELECT run_command_on_workers('ALTER SYSTEM SET pgmongo.azureOpenAIEmbeddingDeploymentName = ''text-embedding-ada-002''');
SELECT run_command_on_workers('SELECT pg_reload_conf()');

```

- Update command
```
SELECT mongo_api_v1.update('db',
    '{"update":"generate_embedding_pipeline",
      "updates":[
             {"q":{},"u":{"**$generateEmbeddings**":{"a":"embeddings"}}, "multi":true}
      ]}'
);
```

- Vector search
```
SELECT document FROM bson_aggregation_pipeline('db',
     '{ "aggregate": "generate_embedding_pipeline",
        "pipeline": [
               { "$search": {
                         "cosmosSearch": { "query": "some sentence", "k": 4, "path": "embeddings", "efSearch": 2 }  }
                  } ,
               { "$count": "_id" }
        ],
        "cursor": {}
      }'
);
```

----
#### AI description  (iteration 1)
#### PR Classification
Refactor to support non-OSS embedding generation and vector search.

#### PR Summary
This pull request refactors update operations and search specifications to support embedding generation in non-OSS environments.
- Added `vector_g...
2024-11-12 18:48:09 +08:00
Deepak Bisht 1225b7ea85 Merged PR 1490664: [InternalError] [Fix] Too many args
### Does this PR have any customer impact?
yes

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

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

### Are you introducing any new config? If yes, do you have tests with and without them being set?
no

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

### Description
For `$group` and `$setWindowFields` we tend to create `bson_repath_and_build` function expression with the path and values as arguments to the function, if this argument list goes beyond 100 its an internal error.

So with this PR huge number of aggregates are broken down using functions expression of `bson_dollar_merge` and `bson_repath_and_build`.
e.g If there are 110 groupby operators then the projector will be of this form.

```
bson_dollar_merge_documents(
    bson_repath_and_build(<50 operators>),
    bson_dollar_merge_documents(
        bson_repath_and_build(<50 operators>),
        bson_repath_and_build(<10 operators>)
    )
)
```

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

#### PR Summary
This pull request addresses an issue with handling too many arguments in aggregation functions by introducing a new method to manage large numbers of arguments.
- `bson_aggregation_pipeline.c`: Added `GenerateMultiExpressionRepathExpression` function to handle cases where the number of arguments exceeds `FUNC_MAX_ARGS`.
- `bson_aggregation_pipeline.c`: Updated `HandleGroup` to use the new function for generating repath expressions.
- `setwindowfields_and_group_compliance.sql`: Added tests to verify the handling of multiple arguments in aggregation functions.
- `bson_aggregation_window_operators.c`: Modified `HandleSetWindowFieldsCore` to use the new function for repath expressions.
- `bson_aggregation_pipeline_private.h`: Declared the new function for generating multi-expression repath expressions.
2024-10-25 09:11:39 +03:00
Deepak Bisht d325973fd0 Merged PR 1424623: $text and $geoNear index support enhancement for mandatory index usage
### 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))
- $geoNear, $near and $nearSphere queries will require suitable geospatial indexes to be present in the collection.

### Description
Make $geoNear require index and fail if no suitable index is found.
Also move $text to same infrastructure to mandate index usage

Steps:
- Check if the index paths are created for Geonear and Text queries in the planner.
- If not update the query tree to only have quals needed to generate the index path and again try to create index path using
`create_index_paths`.
- If the index paths are created then revert back to original query but retain the index path created and allow the query.
- else return error that the indexes were not found for the query
- Clean customsetup.js to not pass key if key is missing is JStest that is handled on the backend now

----
#### AI description  (iteration 1)
#### PR Classification
Enhancement for mandatory index usage in `$text` and `$geoNear` queries.

#### PR Summary
This pull request enhances the support for mandatory index usage in `$text` and `$geoNear` queries by ensuring the appropriate index paths are enforced.
- `planner.c`: Added functions `ProcessQueryOperatorsWithSortClauses` and `ForceIndexForQueryOperators` to handle index path enforcement for special query operators.
- `metadata_cache.c`: Introduced functions `BsonGistGeographyOperatorFamily` and `BsonGistGeometryOperatorFamily` to fetch OIDs for BSON GIST spherical geometries.
- `helio_bson_text_gin.h`: Added `ForceIndexQueryOperatorData` struct to manage index enforcement for special query operators.
- `index_support.c`: Updated `ProcessRestrictionInfoAndRewriteFuncExpr` to set `QUERY_OPERATOR_TEXT` type and handle text index enforcement.
- Removed legacy test cases for `$nearSphere` with coordinate pairs from `bson_query_operator_near_nearsphere.out`.
2024-10-17 11:43:08 +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
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
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 c1e2dcba6c Merged PR 1450846: Port more errors to helio errors
### Does this PR have any customer impact?
No

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

### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes)
No
### Are you introducing any new config? If yes, do you have tests with and without them being set?
No
### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))

### Description
Port more errors to helio for more folders.

----
#### AI description  (iteration 1)
#### PR Classification
Code cleanup to port error codes to Helio-specific error codes.

#### PR Summary
This pull request updates various error codes from Mongo-specific to Helio-specific error codes across multiple files.
- `vector_index_kind_impl.c`: Replaced `MongoBadValue` and `MongoFailedToParse` with `ERRCODE_HELIO_BADVALUE` and `ERRCODE_HELIO_FAILEDTOPARSE`.
- `shard_colocation.c`: Updated error codes from `MongoCommandNotSupported`, `MongoBadValue`, and `MongoFailedToParse` to Helio-specific equivalents.
- `bson_update_operators.c`: Changed error codes like `MongoTypeMismatch` and `MongoBadValue` to `ERRCODE_HELIO_TYPEMISMATCH` and `ERRCODE_HELIO_BADVALUE`.
- `parse_error.h`: Replaced `MongoTypeMismatch` with `ERRCODE_HELIO_TYPEMISMATCH`.
- `collection.c`: Updated error codes from `MongoBadValue` and `MongoInvalidNamespace` to Helio-specific equivalents.
2024-09-12 13:51:02 +03:00
Duan Pei✨ aceb3a89e8 Merged PR 1418208: [Feature] $expMovingAvg implementation
### 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 implementation.

#### PR Summary
This pull request introduces the `$expMovingAvg` aggregation operator to calculate the exponential moving average of numeric values.
- Added new aggregate functions in `oss/pg_helio_api/sql/udfs/aggregation/group_aggregates--1.19-0.sql` for BSON data types.
- Implemented supporting functions in `oss/pg_helio_api/sql/udfs/aggregation/group_aggregates_support--1.19-0.sql`.
- Documented the `$expMovingAvg` operator in `docs/pgmongo/design_docs/data_plane/aggregation_operators/expMovingAvg.md`.
2024-09-05 18:18:23 +03:00
Jayanta Mondal d3c5128254 Merged PR 1405332: Mongo collation support Part 1 ( Find/Aggregate queries with runtime collation)
### Does this PR have any customer impact?
Yes

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

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

### Are you introducing any new config? If yes, do you have tests with and without them being set?
Yes (helio_api.enableCollation). Yes.

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

### Description

Runtime implementation of collation support in Mongo Find query.

We parse the Mongo collation spec and covert it to an ICU standard collation string. An example string is "und-u-ks-level1-kc-true  This string uniquely identify collation-based string comparison logic by Postgres.  See: https://www.postgresql.org/docs/current/collation.html

This document tracks the current support matrix for query operators

| Operator  | Runtime | Index Pushdown | Comments
| --------- | ---- | ----- | ----
|  $eq | Yes | No |
|  $gt | Yes |  No |
|  $gte | Yes | No |
|  $lt | Yes |  No |
|  $lte | Yes |  No |
|  $ne | Yes |  No |
|  $in | No* |  No | See below
|  $nin | No* |  No | Do
|  $and | Yes |  No |
|  $not | Yes |  No |
|  $nor | Yes |  No |
|  $or | Yes |  No |
|  $all | Yes |  No |
|  $elemMatch |  Yes   |  No |
|  $positional | N/A | N/A | positional query operators are only used in projections.
|  $regex | N/A |  N/A   | $regex ignores collations in Native Mongo
|  $exists | N/A  |   N/A   |
|  $size | N/A  |  N/A |
|  $type | N/A |   N/A |
|  $bitsAllClear | N/A  |  N/A  | Not relevant for Utf8
|  $bitsAnyClear | N/A  |  N/A  | Do
|  $bitsAllSet | N/A  |  N/A  | Do
|  $bitsAnySet |  N/A |  N/A  | Do
|  $mod | N/A  |  N/A  | Do
|  $range | N/A  |  N/A | Only applies to Number
|  $text | N/A  |  N/A  | Seprate Index, has its own collation spec
|  $geowithin | N/A   |  N/A  | Not relevant for Utf8
|  $geointersects | N/A    | N/A   | Do

* $in/$nin is implemented with HashMap that does not support collation friendly Hashkeys
* $regex : collations are ignored with
* $text: $text spec has collation specific parameters
* $rage: For numbers only

This document tracks the current support matrix for update operators/commands

| Operator  | Runtime | Index Pushdown |
| --------- | ---- | ----- |
|  find_and_modify | No | No |
|  updateOne | No |  No |
|  updateMany | No | No |
|  createIndex | No | No |

Tests:
1. All Gated Tests pass when Collation is enabled by default

TODO:
1. Index support [already implemented - but breaking down for easy review]
2. Persist collation info while collection created [already implemented - but breaking down for easy review]
3. $cond, $let

Related work items: #3412359
2024-08-26 13:12:13 +03:00
Santiago Fernandez Madero 836b6aaa9e Merged PR 1424086: Add a parse aggregation expression context while parsing the aggregation expressions
Flows a parse aggregation expression context while parsing the expression so that we can track if there were variables, operators, path expressions and do top level validation if needed for things like $let, etc.

----
#### AI description  (iteration 1)
#### PR Classification
API change to add a parse aggregation expression context while parsing aggregation expressions.

#### PR Summary
This pull request introduces a `ParseAggregationExpressionContext` to track the types of expressions encountered during the parsing of aggregation expressions.
- `include/operators/bson_expression_operators.h`: Added `ParseAggregationExpressionContext` parameter to various `ParseDollar*` functions.
- `src/operators/bson_expression_bitwise_operators.c`: Updated bitwise operator parsing functions to include the new context parameter.
- `src/operators/bson_expression_date_operators.c`: Modified date operator parsing functions to use the new context parameter.
- `src/operators/bson_expression_string_operators.c`: Updated string operator parsing functions to include the context parameter.
- `include/operators/bson_expression.h`: Defined the `ParseAggregationExpressionContext` struct.
2024-08-16 18:24:51 +03:00
Rajesh Kumar Thandapani 24704eb978 Merged PR 1409491: Change Stream implementation with Direct WAL decoding (without replication slots)
### Does this PR have any customer impact?
 Yes, it provides support for $changeStream pipeline stage for creating change stream cursor and consuming events from it.

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

### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes)
Adds a new UDF for change_stream_aggregation

### Are you introducing any new config? If yes, do you have tests with and without them being set?
Adds a GUC for enabling ChangeStreams freature and tests have been added to test the feature. It is disabled by default.

### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))
../docs/pgmongo/design_docs/data_plane/change_streams/change_stream_release_notes.md

### Description

This PR implements the change stream tailing cursors using the direct WAL decoding. It avoids using replications slots for logical decoding because of the constraints in creating and decoding with replication slots.

Related work items: #2973720
2024-07-31 17:09:22 +03:00
Vinod Sridharan f64558301b Merged PR 1411883: [Lookup with Let] Fix up some JStests for lookup with Let and misc lookup fixes
### 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?
Yes and Yes
### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))

### Description
- Fix up bugs with $lookup with Let by rewriting lookup to be let friendly
- Get through jstests having lookup with let
-  Optimize Lookup where hte left and right both are on _id to support joins directly on object_id
- Allow the lookup pipeline to be split as "inlined" and "non-inlined" and allow pushing up the inlined pipeline
- Fix bugs with facet/graphlookup arising from Lookup with let tests
- Allow inlining the $unwind path after a $lookup if the $unwind matches a $lookup as (behind a feature flag)
2024-07-31 17:09:22 +03:00
Vinod Sridharan c4ed06beeb Merged PR 1402545: [Let] Support let in all remaining stages except $lookup
### Does this PR have any customer impact?
Not yet

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

### 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
Support remaining aggregation stages except $lookup and $mergeObjects on sorted with $group.
2024-07-31 17:09:22 +03:00
Vinod Sridharan 3cbc0e0037 Merged PR 1400815: [Let support] Add support for let in more stages
### 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)
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))
n/a
### Description
Add support for let in
- $sortByCount
- $group (partial)
- $addFields
- $project
- $facet
- $unionWith
- $graphLookup
- $project
2024-07-31 17:09:22 +03:00
Deepak Bisht 91b9946227 Merged PR 1383926: setWindowFields 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?
No

### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))
- Support for `$setWindowFields` aggregation pipeline stage

### Description
This PR adds the support for `$setWindowFields` aggregation stage using the Postgres `Window aggregation` operators.

For the first PR it only adds support with `$sum` aggregation operator.
Next set of PRs will individually support all the other window aggregation operators supported by `$setWindowFields` stage.

[TODO] Currently $sum is used as is (the way $group uses it), there is way to optimize this using the `Inverse Transition` functions for Window aggregation which modifies the aggregated state in a way to accomodate rows leaving the group in a moving window, which will be done later (this is done to make review on smaller set of files)

Related work items: #2272584
2024-07-11 17:56:53 +03:00
Vinod Sridharan 65a0cf4a46 Merged PR 1399519: Let support: Part 1: Add support for let in find/aggregate
### 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
Add support for `let` in `find` and `aggregate`
- For find ensure that let can be supported both in projection and query.
- For aggregate, so far this is only supported in `$match`.

In subsequent PRs other stages will be reviewed and modified.

Note that this is a precursor to $lookup with let since Lookup's inner pipeline can reference any of those stages that can use `let`

Since this is a partial feature this is guarded with a feature flag.
2024-07-11 17:56:53 +03:00
Parag Jain 0922eac1d7 Merged PR 1391214: [Feature] support for $merge aggregation stage part -2
### Does this PR have any customer impact?
No

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

### 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 of `merge` Action in case of `whenMatched` in `$merge` aggregation stage.

Related work items: #1827100
2024-07-11 17:56:53 +03:00
Santiago Fernandez Madero 017d302a57 Merged PR 1319595: inverseMatch: Support specifying a from collection to avoid the need of a lookup
This PR adds support to specify a from collection within the same database in an inverseMatch aggregation stage.

The spec is as follows:

```
{"$inverseMatch": {"path": <path>, "from": <collection>, "pipeline": <[match | project | limit]> }}
```

Where the input to the inverseMatch evaluation is the result of running the aggregation pipeline against the given collection.
2024-07-05 13:16:04 +03:00
Parag Jain 833980da3f Merged PR 1344998: [Feature] support for $merge aggregation stage part -1
### Does this PR have any customer impact?
No
### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
No
### 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:

**Things this PR has:**
1. support for $merge stage for unsharded collection.
- whenNotMatched : support for `fail` , `discard` and `insert` option.
- whenMatched : support for `replace`, `fail` and `keep-existing` option.

**What next In upcoming PR's :**
1. support for 'merge' option whenMathced
2. support for 'pipeline' option whenMatched.
3. support for sharded collection.
4. support of co-located collection. (one case : when source and taget is same)
5. Index push down for join condition.
6. optimizations in case of sharded collection and unsharded collection for single aggregation stage when we can directly refer source shard_key_column.

Related work items: #3085830
2024-07-05 13:16:04 +03:00
Jia Hu 👻 8a67d6e2b3 Merged PR 1332883: vector search - add support for $vectorSearch
### 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
### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))

### Description
support for $vectorSearch in aggregation pipeline.
2024-06-21 18:21:38 +03:00
Lucas Borges Fernandes 025a9452dc Merged PR 1321307: Merge Objects accumulator for group by aggregation
### Description

Implementation of the $mergeObjects accumulator.

Reference: https://www.mongodb.com/docs/manual/reference/operator/aggregation/mergeObjects/

Related work items: #2988409
2024-06-21 18:21:38 +03:00
Deepak Bisht 05c3a40f06 Merged PR 1316036: [GeoNear] Part 2 - GeoNear JSTest infra and added new distance range operator that is pushed to indexes
### 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

### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))
Added support for $geoNear aggregation stage pipeline.

### Description
Part 2  for supporting geoNear stage

This fixes following TODOs from the last PR:

1. Push `$minDistance` and `$maxDistance` to index similar to mongo. ✅
=================
Created a new range distance query operator `@|><|` which is supported by both `2d` and `2dsphere` indexes. $geoNear now uses this instead of float8 distance less than / greater than comparisions.

1. [TODO] Make the stage require an index always. ❌
=================
$geoNear queries always require a geo index in mongo

1. Fix projection for nested array fields. ✅
=================
$geoNear projection for `distanceField` or `includeLocs` overrides the intermediate array nodes instead of recursing into arrays and updating each element.

1. Make common test setup for running $geoNear queries in JSTests which don't require key in mongo. ✅
=================
Mongo JSTests mostly create single geo index on the collection and misses the `key` option for $geoNear stage, so we override couple of mongo functions to make sure if we are using the $geoNear stage then we can update the pipeline to contain the respective `key` field, so that tests can run without failure.

1. More testing and validations with other stages that can use $geoNear. ✅
1. Test batching and cursor support. ✅
1. Overall testing and validations ✅
1. $geoNear Tests passed: **Out of 23 test dependent on $geonear now 9 are passing**, and rest are again dependednt on $near and $nearSphere which is a subset of $geonear

Related work items: #2782870, #2782872
2024-06-03 13:12:17 +03:00
Vinod Sridharan 2a2bc2d8a0 Merged PR 1365133: Fix take 3: Push the fix into the 1.16 schema hotfix train
### 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)
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
Push the $lookup fix into the 1.16 schema hotfix train
2024-06-03 13:12:17 +03:00
Vinod Sridharan 6a7883c578 Merged PR 1364352: [Prep] Hotfix Prep for changes for $lookup internal 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

Allow the $lookup changes to happen in 1.17-1
2024-06-03 13:12:17 +03:00
Vinod Sridharan 67519437d4 Merged PR 1362229: Fix lookup for paths that have operator like syntax
### 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)
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
Fix scenarios where the documents may have $prefixed nested fields.
When doing lookup this was treated as an operator instead of a field throwing an error
Introduce a bson_dollar_merge_documents which ignores operators and simply merges the documents directly.
2024-06-03 13:12:17 +03:00
Santiago Fernandez Madero 73e78bd4aa Merged PR 1358512: [let 2/n] Add $let aggregation operator
### 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 adds support for `$let` aggregation operator, it also includes some bugfixes around variables at variable name validation and reverts flowing the variable context at parse time since there was a way to do it without flowing it.

Split in 2 commits to make easier reviewing, one for $let support and the other one to revert flowing the variable context at parse time.
2024-06-03 13:12:17 +03:00
Santiago Fernandez Madero d075283e14 Merged PR 1345825: [let 1/n] - Make variables part of aggregation expression data and support expressions as the variable value
### 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

Make variables part of aggregation expression data and support expressions as the variable value. Also this flows the variable context through projection tree which is needed to support lookup let and also let on update and find (top level let).

Once this is in, next PR will be to support the $let aggregation operator, which will set the variable context at parse time for it's child expressions.
2024-05-24 10:41:23 +03:00
Jia Hu 👻 f7fc1d3bfd Merged PR 1315834: add array operator: $map, $reduce
### 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
### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))

### Description
add array operator: $map, $reduce

Related work items: #2019117, #2019128
2024-04-19 12:03:52 +03:00
Deepak Bisht 58afe0aa8f Merged PR 1275776: [Pgmongo] - Part 1 GeoNear aggregation stage, add documentation and necessary operators and functions
### 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

### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))
Support $geoNear aggregation stage

### Description
Add the design doc and necessary operators and functions needed for $geoNear

Also,
1-  Implement the $geoNear aggregation stage skeleton and support all options.
     - `distanceField`,
     - `near` (both legacy, geojson point)
     -`includeLocs`,
     -`minDistance` & `maxDistance`
     - `distanceMultiplier`
     - `key`
2- Support index pushdown of the stage to `2d` and `2dspher` index.
    - spherical / non-spherical distance support for `2d` index.
    - spherical distance support for `2dsphere` index

Things still a TODO.
1- ~~Update the mongo explain plans for geonear stage~~.
2- Make the stage require an index always, currently it can be executed without index too.
3- Fix projection for nested array fields.
4- Make common test setup for running $geoNear queries in JSTests which don't require key in mongo.
5- More testing and validations with other stages that can use $geoNear.
6- Test batching and cursor support.
7- Overall testing and validations

Related work items: #3000189, #3065270
2024-04-19 12:03:52 +03:00
Vinod Sridharan 2da6633812 Merged PR 1314099: Colocation Support Part 2
### 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)

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

### Description
2024-04-05 13:43:51 +03:00
Vinod Sridharan 7c778c19f8 Merged PR 1296261: Graphlookup part2 - Enable Tests and fix up issues
### 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)

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

### Description

From the remaining TODOs handles the following:

- [Done] To handle arrays we do a `$unwind` - move that to doing an eq/in based on the input: This is done by adding a makeArray aggregation operator and using that with `$in` expression
- [Done] Think about cycles: Add a visited check and ignore nodes that are visited before.
- [Done] Need to handle maxDepth infinite recursion more gracefully with $graphLookup.
- [Done] Need to validate against jstests

Still TODO:
- More testing on dotted paths and arrays & reducing traversals
- Implement a hash aggregate operator class for BSON
2024-03-22 11:28:50 +03:00
Vinod Sridharan 6a699bcd46 Merged PR 1289862: Part 1: Skeleton for the GraphLookup 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

### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))
N/A
### Description
Implement the basic skeleton for $graphLookup under a feature flag.

Remaining TODOs:
1) To handle arrays we do a $unwind - move that to doing an $eq/$in based on the input
2) Implement a hash aggregate operator class for BSON so we can use a UNION query instead of UNION ALL
3) Need to validate against jstests
4) Need to handle maxDepth infinite recursion more gracefully with $graphLookup.
5) More testing on dotted paths and arrays
6) Think about cycles

Related work items: #1798581
2024-03-08 14:01:20 +03:00
Vinod Sridharan c00dcf25a4 Merged PR 1288370: [Tests] Make more tests pass
### 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
### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))
N/A
### Description
Make more JSTests pass by implementing or fixing bugs
2024-03-04 09:53:14 +03:00
Vinod Sridharan 38ae02ad41 Merged PR 1286968: [JSTests] Make exclusion test pass
### 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)

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

### Description

More

Related work items: #2453917
2024-03-01 17:24:28 +03:00
Vinod Sridharan 0e156314f6 Merged PR 1282170: [PG16] Enable building the extension with PG16
### Does this PR have any customer impact?
No

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

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

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

### Description
Part 1: Enable building the extension and fix up pieces for building with PG16.

With this the core extension builds with PG16 and *most* of the backend tests pass. At this point, checking this in as a checkpoint (to ensure compat is retained) as more features are lit up with PG16

One thing to note is PG16 builds changes the default visibility of exports to 'private' that means that to make the current build work, we need to override that to 'default/public'. This needs to be fixed but is left as-is currently to make incremental progress.

There were some attempts to create exports in the code that are left as-is
2024-03-01 17:24:28 +03:00
Zinan Ren 🐾 69118d324f Merged PR 1246367: [Vector Search] Support pre-filtering in search - Part 2
### Known limitations & TODO for part 2
- [ ]  The current implementation intersects results from both vector index and bitmap index, it is actually the post-filtering
- [ ]  Not work for sharded collection

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

### New explain result
![image (5).png](https://msdata.visualstudio.com/ba574a88-a171-48e0-8fcb-5fef6d23739c/_apis/git/repositories/501a5e7e-ffdc-4d1e-a5e6-910f73c6eb9a/pullRequests/1246367/attachments/image%20%285%29.png)
From mongo command:
```
SELECT document FROM
    bson_aggregation_pipeline('db', '
        {
        "aggregate": "aggregation_pipeline_ivf_filter",
        "pipeline": [
                {
                "$search": {"cosmosSearch": { "vector": [ 3.0, 4.9, 1.0 ], "k": 4, "path": "v", "filter": { "a": "some sentence" }, "nProbes": 1 }  }
                }
        ],
        "cursor": {}
}');

```
To psql command
```
1. SELECT c1(search query):
			SELECT
				document,
				(public.vector(mongo_catalog.bson_extract_vector(collection.document, 'v'::text), 3, true) OPERATOR(public.<=>) public.vector(mongo_catalog.bson_extract_vector('{ "vector" : [ { "$numberDouble" : "3.0" }, { "$numberDouble" : "4.9000000000000003553" }, { "$numberDouble" : "1.0" } ], "k" : { "$numberInt" : "1" }, "path" : "v" }'::mongo_catalog.bson, 'vector'::text), 3, true)) AS orderVal,
				ctid
			FROM
				mongo_data.documents_1 collection
			WHERE
				shard_key_value = 0
				AND ((mongo_catalog.bson_extract_vector(collection.document, 'v'::text) IS NOT NULL))
			ORDER BY
				(public.vector(mongo_catalog.bson_extract_vector(collection.document, 'v'::text), 3, true) OPERATOR(public.<=>) public.vector(mongo_catalog.bson_extract_vector('{ "vector" : [ { "$numberDouble" : "3.0" }, { "$numberDouble" : "4.9000000000000003553" }, { "$numberDouble" : "1.0" } ], "k" : { "$numberInt" : "1" }, "path" : "v" }'::mongo_catalog.bson, 'vector'::text), 3, true))
2. SELECT c2(filter query):
			SELECT
				ctid
			FROM
				mongo_data.documents_1
			WHERE
				shard_key_value = 0
				AND document @@ '{ "a": "some sentence" }'

3. JOIN c1 ON c1.ctid = c2.ctid
			SELECT
				c1.document
			FROM c1 JOIN c2 ON c2.ctid = c1.ctid
			ORDER BY c1.orderVal
			LIMIT 1
```

Related work items: #2586299
2024-02-07 23:20:07 +03:00
Vinod Sridharan da2c098f3c Merged PR 1265302: Make sh.status() work
### 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

### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))
Make sh.status() work in mongo shell.

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

With these changes, this now looks like:
![image (2).png](https://msdata.visualstudio.com/ba574a88-a171-48e0-8fcb-5fef6d23739c/_apis/git/repositories/501a5e7e-ffdc-4d1e-a5e6-910f73c6eb9a/pullRequests/1265302/attachments/image%20%282%29.png)
2024-02-07 23:20:07 +03:00
Lucas Borges Fernandes 9839f0610e Merged PR 1249793: Changing extension name to helio in all OSS files
Removing references from the old extension name.
2024-01-17 22:08:45 +03:00
Vinod Sridharan d8671eb379 Initial commit for HelioDB 2024-01-12 19:10:20 +00:00