Commit Graph
220 Commits
Author SHA1 Message Date
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
Vinod Sridharan 5dbc8843d4 Merged PR 1398308: [Colocation] Support colocation with Transaction isolation
### 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
- If we have 2 concurrent tables being created in 1 DB then they get colocated in 2 different groups.
- Prevent this by using a common table per db (system.dbSentinel).
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
Shuai Tian 🚀 b3a934c5a4 Merged PR 1397255: disallow dots in group output field names to make one jstest pass
### 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

disallow dots in group output field names, to make this test pssed: jstests\aggregation\bugs\server6198.js
2024-07-11 17:56:53 +03:00
Parag Jain 3869e5ae56 Merged PR 1395986: Adding a GUC for support for $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
Adding a GUC for support for merge across DB.

After Latest colocation changes : https://msdata.visualstudio.com/CosmosDB/_git/pgmongo/pullrequest/1394549

For unsharded collections, if the source and target tables are in different databases, they will not be colocated. Additionally, unsharded collections no longer use HASH_DISTRIBUTION. As a result, Citus does not support the repartitioning strategy and the operation fails.

Currently, cross-database support is available under GUC until we have a fix in Citus.
2024-07-11 17:56:53 +03:00
Ujjwal Agrawal 235df34099 Merged PR 1371362: add 2d index bounds 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

Add check that the geoNear query's reference point is within the geo bounds added in the index

Related work items: #3263902
2024-07-11 17:56:53 +03:00
Ayush Saluja 66d1e7a0c0 Merged PR 1395909: [pgmongo] bugfix for max pipeline depth jstest pass $unionWith and $lookup
### 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 the bugbash found that we need to fix max depth for $lookup and $unionWith stages.
Enabled the jstest for the same
2024-07-11 17:56:53 +03:00
gledis69 a855fe305a Silly commit for testing 2024-07-11 14:53:41 +03:00
gledis69 29392a3880 Add internal compatibility test 2024-07-11 14:53:41 +03:00
Vinod Sridharan fb71d32668 Merged PR 1394549: Take 2: Fixes with colocation and Citus 12
### 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

Take 2: Fixes with colocation and Citus 12
2024-07-05 13:16:04 +03:00
Deepak Bisht 5cb7bf4ca5 Merged PR 1394849: Geospatial Internal self intersection errors for $polygon
### 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))
- Bugfix with $polygon self intersecting geometry

### Description
MongoDB is not restrictive when the 2d polygon is created using `$polygon`

Here the polygon defined by `$polygon` is not a valid polygon as it intersects with itself
`[[10, 10], [10, 12], [11, 11], [9, 11]]`

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

But similar query in Postgis would not work and we can always make them valid using ST_makevalid:
![image (2).png](https://msdata.visualstudio.com/ba574a88-a171-48e0-8fcb-5fef6d23739c/_apis/git/repositories/501a5e7e-ffdc-4d1e-a5e6-910f73c6eb9a/pullRequests/1394849/attachments/image%20%282%29.png)
2024-07-05 13:16:04 +03:00
Shuai Tian 🚀 4eb63103f3 Merged PR 1359786: Add $bucket stage doc and 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
Add bucket aggregation stage

Query time comparison for $bucket between Atlas and vCore:
https://microsoftapc-my.sharepoint.com/❌/g/personal/shuaitian_microsoft_com/EduvH4BY2O9Dnt92siIPJlUBOF5DNKNeF4BSQ6NeyZO-iQ?e=xGAuIC

Related work items: #1798584
2024-07-05 13:16:04 +03:00
Parag Jain 9d7187e746 Merged PR 1394555: [Fixes] memory allocation and free related fixes PCRE2
### 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 has fix :
1. use palloc and pfree for match context by passing general context which knows about custom functions.

![image (3).png](https://msdata.visualstudio.com/ba574a88-a171-48e0-8fcb-5fef6d23739c/_apis/git/repositories/501a5e7e-ffdc-4d1e-a5e6-910f73c6eb9a/pullRequests/1394555/attachments/image%20%283%29.png)
2024-07-05 13:16:04 +03:00
Vinod Sridharan 70057eff24 Merged PR 1395389: Colocation, Merge & Update changes
### 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
- DIsable Colocation by default in utils.sh until we have citus single shard distributed table support for merge.
- Fix Citus 12.1 usage in the pipelines
- Enable update unsharded optimization by default.
2024-07-05 13:16:04 +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
Ujjwal Agrawal 5d50087869 Merged PR 1387494: Geospatial code cleanup
### 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

geospatial code cleanup
2024-07-05 13:16:04 +03:00
Vinod Sridharan 204950f55c Merged PR 1391279: [Unique] Unique error constraint should have the Index name in the error
### 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
Unique error constraint should have the Index name in the error
2024-07-05 13:16:04 +03:00
Jia Hu 👻 36e84429da Merged PR 1387090: Schema validation wave 1 - fix and add feature flag
### 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?

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

### Description

Add feature flag for schema validation.

Related work items: #3296102
2024-07-05 13:16:04 +03:00
Vinod Sridharan f4ce1f8ae2 Merged PR 1390611: [Background Worker] Spin up background worker behind a feature flag
### 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 - feature flags
### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))

### Description
Create background worker stub - this worker does nothing other than sleep.
Only turn this on behind a feature flag and enable it for backend tests only.
2024-07-05 13:16:04 +03:00
Lucas Borges Fernandes 95f55fbe86 Merged PR 1380779: Enabling index term truncation by default
### Description
With this PR we make the GUC **helio_api.enable_large_index_keys = true** for every new cluster. If this GUC is not explicitly set to false, then we enable index truncation it if the index supports it.
2024-07-05 13:16:04 +03:00
Ayush Saluja 984485c80c Merged PR 1382299: [pgmongo] $dateFromString supporting extra format specifiers for 7.0 compat
### Does this PR have any customer impact?
Yes

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

### 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
1) In mongo 7.0 for dateFromString new format specifiers are added to support month names and dayOfYear while parsing.
Have added support for them

2) In this pr for %j format specifier we have taken the call to increase the allowed limit from 366 to 999 .
As per mongo documentation they mention the allowed values are in range 1-366 but implementtion wise they have the range as 999
Hence, while defining the range for %j used 999

Related work items: #3297388
2024-07-05 13:16:04 +03:00
Deepak Pemmaraju f3b17295f5 Merged PR 1381452: changing schema for user CRUD
### 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

changing schema for user CRUD
2024-07-05 13:16:04 +03:00
Vinod Sridharan 07c3bba78c Merged PR 1390575: [Toshiba fixes] Fix up version handling and code cleanups
### 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
- Delete dead configs
- Reduce number of calls to check version information
- Move ExtensionVersion checks to shared memory
2024-07-05 13:16:04 +03:00
Deepak Bisht c7d95d63c4 Merged PR 1389738: Enhance explain for geo operators
### 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
- Add geo operators in explain `runtimeFilterSet` and `indexFilterSet`
Before
![image.png](https://msdata.visualstudio.com/ba574a88-a171-48e0-8fcb-5fef6d23739c/_apis/git/repositories/501a5e7e-ffdc-4d1e-a5e6-910f73c6eb9a/pullRequests/1389738/attachments/image.png)

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

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

- Add  `GEO_NEAR_2d` and `GEO_NEAR_2dsphere` as stage names for aggregation
2024-07-05 13:16:04 +03:00
Deepak Bisht ee9d9addca Merged PR 1390003: Move geonear functions to 1.17-2
### Does this PR have any customer impact?
No

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

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

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

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

### Description

1. Move geonear schema changes to 1.17-2
2. Update cluster version required for $geoNear, $near and $nearSphere to be 1.17-2
2024-07-05 13:16:04 +03:00
Vinod Sridharan b0caf152ea Merged PR 1390378: Prod internal error bugbash fixes
### 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

- BSON Send needs to copy the bytes
- Skip 0 should be skipped
- Handle internal error for max key size for _id.
2024-07-05 13:16:04 +03:00
Vinod Sridharan cfcfe640cc Merged PR 1386895: [Unwind] Small improvement in unwind
### Does this PR have any customer impact?
Yes

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

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

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

### Description
- Fixup Unwind in the optimistic case where the source doc end up being unmodified.
- Fix up explain for parallel scan queries
2024-07-05 13:16:04 +03:00
Duan Pei✨ 9f977c084b Merged PR 1352447: $bitAnd/$bitOr/$bitXor/$bitNot operators
### 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))
No
### Description
Implementation of bitwise aggregation operators

### Error handling instructions:
#### bitk2 collection:
![image.png](https://msdata.visualstudio.com/ba574a88-a171-48e0-8fcb-5fef6d23739c/_apis/git/repositories/501a5e7e-ffdc-4d1e-a5e6-910f73c6eb9a/pullRequests/1352447/attachments/image.png)
#### bitNot:
##### [1,2,"$a"] and $c have different processing logic:
![image (3).png](https://msdata.visualstudio.com/ba574a88-a171-48e0-8fcb-5fef6d23739c/_apis/git/repositories/501a5e7e-ffdc-4d1e-a5e6-910f73c6eb9a/pullRequests/1352447/attachments/image%20%283%29.png)
##### Error messages for [2.1] and ["$c"]
![image (8).png](https://msdata.visualstudio.com/ba574a88-a171-48e0-8fcb-5fef6d23739c/_apis/git/repositories/501a5e7e-ffdc-4d1e-a5e6-910f73c6eb9a/pullRequests/1352447/attachments/image%20%288%29.png)

#### bitAnd (bitAnd bitOr bitXor error handling logic is consistent):
![image (5).png](https://msdata.visualstudio.com/ba574a88-a171-48e0-8fcb-5fef6d23739c/_apis/git/repositories/501a5e7e-ffdc-4d1e-a5e6-910f73c6eb9a/pullRequests/1352447/attachments/image%20%285%29.png)
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 👻 7c1104ee62 Merged PR 1371339: Schema validation wave 1 - create/update/get for metadata
### 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
wave1 - create/update/get for schema validation metadata
2024-07-05 13:16:04 +03:00
Santiago Fernandez Madero d20b3e65dd Merged PR 1378322: Improve update performance for unsharded collections on multi-node
### 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

Improve update performance for unsharded collections on multi-node

Before this change we were iterating the update batch on the coordinator and sending the individual update spec to the worker node, so if the batch was of 500, that meant 500 calls to the worker node and serializing/deserializing the update spec and the result.

For unsharded collections we can just push down the whole batch of updates to the worker since the documents live in a single shard and process the batch there, going from 1 call per each update to 1 call for all updates.

With this improvement, on my local box with a collection of 2 million documents of 1kb and a batch update of 500 documents I see the following improvements:

Before: ~520ms
After: ~220ms

That's roughly 50% improvement.

The feature is disabled behind a GUC so that we can test it and slowly enable it since it changes a critical code path.

Next, we could probably reduce the 270ms further more for unsharded updates where the filter query operates on the _id node, that will be investigated and done on a separate PR.

Also, sharded and single node queries should benefit from this change a bit (around a 10-15%) because we're removing calculating the update of the document from the SELECT FOR UPDATE query in SelectUpdateCandidate and instead, just select the candidate and perform the update in code directly.
2024-06-21 18:21:38 +03:00
Ujjwal Agrawal 265b6ed60c Merged PR 1370285: Support legacy pair array with geospatial runtime
### 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

support legacy pair array with centerSphere. Native behaviour looks like following, supporting similar behaviour -

```
> db.coll.find()
{ "_id" : ObjectId("666016ebb648c6bfc6008730"), "geo" : [ { "x" : 1, "y" : 1 }, { "x" : 2, "y" : 2 }, { "x" : 3, "y" : 3 } ] }
{ "_id" : ObjectId("666016f0b648c6bfc6008731"), "geo" : [ [ 1, 1 ], [ 2, 2 ], [ 3, 3 ] ] }
> db.coll.getIndexes()
[
        {
                "v" : 2,
                "key" : {
                        "_id" : 1
                },
                "name" : "_id_"
        },
        {
                "v" : 2,
                "key" : {
                        "geo" : "2d"
                },
                "name" : "geo_2d"
        }
]
> db.coll.find({geo: {$geoWithin: {$centerSphere: [[0,0], 1]}}})
{ "_id" : ObjectId("666016ebb648c6bfc6008730"), "geo" : [ { "x" : 1, "y" : 1 }, { "x" : 2, "y" : 2 }, { "x" : 3, "y" : 3 } ] }
{ "_id" : ObjectId("666016f0b648c6bfc6008731"), "geo" : [ [ 1, 1 ], [ 2, 2 ], [ 3, 3 ] ] }
> db.coll.createIndex({geo: "2dsphere"})
{
        "ok" : 0,
        "errmsg" : "Index build failed: 44278214-23a2-466f-9fa8-78f385840fb5: Collection test.coll ( a0395bdf-8f3e-4ca7-9426-8d741b3ca75d ) :: caused by :: Can't extract geo keys: { _id: ObjectId('666016ebb648c6bfc6008730'), geo: [ { x: 1.0, y: 1.0 }, { x: 2.0, y: 2.0 }, { x: 3.0, y: 3.0 } ] }  Point must only contain numeric elements, instead got type object",
        "code" : 16755,
        "codeName" : "Location16755"
}
```

Related work items: #3256077
2024-06-21 18:21:38 +03:00
Deepak Bisht e0eb8d5591 Merged PR 1378201: Geospatial GA readiness
### Does this PR have any customer impact?
No

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

### 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))
Geospatial General Availability

### Description
Enable geospatial feature by default and update doc
2024-06-21 18:21:38 +03:00
Lucas Borges Fernandes 202e7b058a Merged PR 1367431: Add support for wildcard index truncation
### Description

This PR removes the hard block for wildcard indexes with truncation. We set a maximum (configurable) size for index keys in order to leave room for data.
2024-06-21 18:21:38 +03:00
Santiago Fernandez Madero ebf487f2a4 Merged PR 1370848: Bump main to 1.19
### 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

Bump main to 1.19
2024-06-21 18:21:38 +03:00
Deepak Bisht a19d90fef0 Merged PR 1371674: [pgmongo] - Fix distinct / findAndModify to consider all sort clauses,
### 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
1. $near/ $nearSphere add sort clause and target entry to the query AST which is needed to be pushed down to a subquery in a distinct call.

2. Remove the requirement of `Query` node to build the `near/nearSphere` in query_operators.c. Added 2 new fields to `BsonQueryOperatorContext` that holds referrence to the `sort clauses` and `target entries` for the sort clauses which can be added back to the `Query` node.

Related work items: #3248030
2024-06-21 18:21:38 +03:00
Jayanta Mondal d2bb6e4486 Merged PR 1374316: [Bugs] Fix lookup crash on _id ForeignField on a target sharded collection
### Does this PR have any customer impact?
Yes

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

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

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

### Description

Fix lookup crash. We can't push down when joining on "_id" when target collection is sharded.

Push down introduced in this:https://msdata.visualstudio.com/CosmosDB/_git/pgmongo/pullrequest/1325613

Related work items: #3279580
2024-06-21 18:21:38 +03:00
Ujjwal Agrawal cabe123eee Merged PR 1358935: $near and $nearSphere impl
### 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

Related work items: #3116418, #3244312
2024-06-21 18:21:38 +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
Deepak Pemmaraju c44eb4ae23 Merged PR 1359979: Adding a read only role in the backend
### Does this PR have any customer impact?
By default, no. Not unless they choose to use the read only role.

### 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))
New Feature

### Description
Adding a readonly role in the backend. The goal is to enable native readonly users in Mongo VCore

Related work items: #3141137, #3158558
2024-06-21 18:21:38 +03:00
Ujjwal Agrawal dfaad4c544 Merged PR 1365793: Update radius of earth
### 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

change radius of earth to fix - bug #3051673

Results before fix -
```
mongos> db.coll.find({geo: {$geoWithin: {$centerSphere: [[0,0],  0.017453292519943295]}}})
{ "_id" : ObjectId("665823821a4e2ed433cb590f"), "geo" : [ 0, 0 ], "d" : 0 }
{ "_id" : ObjectId("665823ad1a4e2ed433cb5915"), "geo" : [ 0, 1 ], "d" : 0.017453292519943295 }
{ "_id" : ObjectId("665823b11a4e2ed433cb5917"), "geo" : [ 0, -1 ], "d" : 0.017453292519943295 }
```

Results after fix -

```
mongos> db.coll.find({geo: {$geoWithin: {$centerSphere: [[0,0],  0.017453292519943295]}}})
{ "_id" : ObjectId("665823821a4e2ed433cb590f"), "geo" : [ 0, 0 ], "d" : 0 }
{ "_id" : ObjectId("6658239e1a4e2ed433cb5911"), "geo" : [ -1, 0 ], "d" : 0.017453292519943295 }
{ "_id" : ObjectId("665823a81a4e2ed433cb5913"), "geo" : [ 1, 0 ], "d" : 0.017453292519943295 }
{ "_id" : ObjectId("665823ad1a4e2ed433cb5915"), "geo" : [ 0, 1 ], "d" : 0.017453292519943295 }
{ "_id" : ObjectId("665823b11a4e2ed433cb5917"), "geo" : [ 0, -1 ], "d" : 0.017453292519943295 }
```

Related work items: #3051673
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 b9db5b64cb Merged PR 1366049: Fix cursor cost with streaming cursors
### 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)

### 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
- SingleBatch cursors with streaming cursors still had the custom scans and overhead
- Primary key lookup with custom streaming scans had the issue of potentially picking SeqScan due to costs changing after converting index scan -> bitmap scan.

Fix both these scenarios.

Support adding EXPLAIN with cursors to track these easier with tests.
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
Ayush Saluja f09abd69e9 Merged PR 1363060: [pgmongo]$replaceAll Bug fix
### Does this PR have any customer impact?

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

fixing bug for $replaceAll.

When we try to replace this

t.aggregate([{$project: {replacedText: { $replaceAll: { input: "foo bar", find: "o", replacement: "O" } }}}])
{ "_id" : ObjectId("6654594ae0e0158ce47550f6"), "replacedText" : "fOobar" }

Output should be
{ "_id" : ObjectId("6654594ae0e0158ce47550f6"), "replacedText" : "fOObar" }

Related work items: #3220469
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
Vinod Sridharan 8b8e029699 Merged PR 1360629: [Perf] Skip/Limit + RUM scan perf improvements
### Does this PR have any customer impact?
Yes

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

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

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

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

### Description

1) When Skip: 0 & Limit: 0 this means that skip and limit are unset. We did this correctly, but that case is streamable as a cursor. We treat this as a persistent cursor leading to connection usage being less optimal. This fixes that to make skip/limit being streamable
2) Log extension versions every hour so that we can track this in Flex
3) For Bitmap scans with compare partial we use a tuplestore and store the Tids for the matching entries. While this is good, a TidBitmap is more efficient in storing TIDs. a tuple store stores it as (Block, Offset), (Block, Offset) ....
vs TIDBitmap stores it as (Block, Offset; Offset;Offset;Offset) (Block, Offset;Offset;) which is more efficient but also makes it lossy to preserve memory. In cases where the size fits in memory (under ~65K pages touched) this performs better than a tuplesort. After that, it still performs better if the intersection of the terms is small. Switch to this mode for tidbitmap where the bitmap is already lossy.

For certain bitmap scans, this brought the runtime from 1.2s to ~280ms.
2024-06-03 13:12:17 +03:00