### 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
### 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
### 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.
### 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.
### 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
### 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
### 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.
### 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
### 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
### 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
### 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.
### 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.
### Does this PR have any customer impact?
Yes
### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
Perf/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 unsharded collections we create 32 connections per table for create indexes and only 1 of them does any work: Use sequential access to better utilize connections.
### 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.
### 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 aims to support $dateFromString operator.
Since this has multiple parts and complexity to it this part of the pr will take care of handling all the input strings and parsing them with the given input format and incase format is not specified we use for now Default format to parse the dateString. If not parseable we throw error.
In next set of pr we will aim to parse the string when format is not specified with even more format checks
Related work items: #2019204
### 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
$sortArray (aggregation) operator
Related work items: #2019138
### 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))
No
### Description
Add support for $maxN/ $minN aggregation array operator.
Related work items: #2019119, #2019127
### 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
Add array operator: $zip
Related work items: #2019134
### Does this PR have any customer impact?
No. It does not have any customer impact, since the UDF is not exposed to users in this PR.
### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
Feature. It introduces infrastructure and an UDF for implementing Change Streams.
### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes)
Change Stream Aggergation stage UDF(change_stream_aggregation) has been added in this PR.
### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))
The release notes for this feature is available here:
docs/pgmongo/design_docs/data_plane/change_streams/change_stream_release_notes.md
### Description
### Description
This PR implements the change stream aggregation UDF `change_stream_aggregation`
It adds some unit tests for testing change stream.
# Supported Features
Currently, the $changeStream aggregation supports only these features:
1) Watching a collection for the following change events:
a) INSERT
b) UPDATE:
NOTE: UPDATe event always provides the new document after update.
The update_description field is not supported yet.
c) DELETE
2) Resuming the change stream from a particular event using the "_id" field in the change event
or the "postBatchResumeToken" field in the change stream cursor.
# Current Limitations:
1) The following events are not supported:
a) create
b) createIndexes
c) drop
d) dropDatabase
e) dropIndexes
f) invalidate
g) refineCollectionShardKey
h) rename
i) replace: NOTE: this event is published as "UPDATE" currently.
j) reshardCollection
k) shardCollection
NOTE: Expanded Events:
The above list includes expanded events also. The option "showExpandedEvents" is not supported.
2) Unsupported change stream pipeline options:
All the options other than "resumeAfter" is not currently supported, and will result in an error.
NOTE: Hisstorical change stream events are not supported "startAtOperationTime"
So change streams can be created from the current time only.
3) Change Stream targets:
Currently, $changestream aggregation can be applied at collection level only. Not at the database/cluster level. But Multiple change streams can be opened on multiple collections.
But the current default maximum limit on parallel change streams by default is "5".
4) Support for multi node clusters.
Change Streams are supported only at the single node clusters.
### Does this PR have any customer impact?
Yes
### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
Bugfix + 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
This covers a few issues uncovered in customer investigations:
1) Explain doesn't show the new $not operators and instead uses $unknown
2) For streaming cursors we can't support parallel scans since that could reorder the tuples and make us miss results. If we have a streaming cursors - remove the parallel plan altogether
3) For non-streaming cursors, always prefer index paths over parallel seqscans - this is because our statistics aren't great and on large docs (esp with LIMIT) the selectivity makes the planner think a parallel path can be faster. We can re-evaluate this with statistics later
4) For non-streaming cursors with LIMIT, allow index scans instead of bitmap scans with a GUC. This also needs to be paired with the RUM enable_semifast_gettuple - this is behind a GUC to allow for validation of correctness. Outside of LIMIT scenarios do not allow this yet.
Note: This is not yet enabled for TTL purger since we want to improve that case with an improvement inside amgettuple first.
### 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))
N/A
### Description
Don't let citus.max_client_connections affect LibPQ connections by marking these connections as internal
### Does this PR have any customer impact?
May be.
### 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))
N/A
### Description
Mongo allows only one text index. We also allowed once. But when someone created the second index, we said that an equivalent index exists instead of saying one can't create more than one text index.
### 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
### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))
Adds index pushdown for $not operators
### Description
Adds index pushdown for $not operators
### Does this PR have any customer impact?
No (Behind a feature flag)
### 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
Improve perf for single node - go for the shard directly if it’s available improving single node perf.
For perf results we see
YCSB Read: 8000 reads/sec. (Up from 6300)
YCSB Update: 1745 ops/sec ( from 1550)
YCSB Insert: 1760 ops/sec (from 1550)
### 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
1. Reduce default value of cron job schedule to 2 seconds for Index Build background feature.
Though, the Index Build background feature is behind GUC (disabled by-default)
2. Disable cron job for upgrade test, we have seen flakiness in the test
3. DropIndexes should be able to cancel CreateIndexes as right owner so that execution of DROP INDEX CONCURRENTLY is cleaner and it does not conflict with CREATE INDEX CONCURRENTLY
Sample serverside logs for 3rd point
```
2024-04-16 16:54:34.990 UTC [40693] LOG: Cancel existing index build request for 6 is completed.
2024-04-16 16:54:34.990 UTC [40693] STATEMENT: CALL mongo_api_v1.drop_indexes_concurrently($1, $2)
**2024-04-16 16:54:34.991 UTC [40704] WARNING: CONCURRENTLY-enabled index commands can fail partially, leaving behind an INVALID index.
Use DROP INDEX CONCURRENTLY IF EXISTS to remove the invalid index.
2024-04-16 16:54:34.991 UTC [40704] ERROR: canceling statement due to user request
2024-04-16 16:54:34.991 UTC [40704] HINT: canceling statement due to user request
2024-04-16 16:54:34.991 UTC [40704] STATEMENT: CREATE INDEX CONCURRENTLY documents_rum_index_6 ON mongo_data.documents_1 USING pgmongo_rum ( document mongo_catalog.bson_rum_single_path_ops(path='_id'), document mongo_catalog.bson_rum_single_path_ops(path='vendorItemId'))
2024-04-16 16:54:34.991 UTC [40705] ERROR: canceling statement due to user request
2024-04-16 16:54:34.991 UTC [40705] HINT: canceling statement due to user request**
2024-04-16 16:54:34.991 UTC [40705] STATEMENT: CREATE INDEX CONCURRENTLY documents_rum_index_6_102045 ON mongo_data.documents_1_102045 USING pgmongo_rum (document mongo_catalog.bson_rum_single_path_ops (path = '_id' ) ,document mongo_catalog.bson_rum_single_path_ops (path = 'vendorItemId' ) )
Related work items: #3109561
### 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
CURRENT is a system variable that points to ROOT (current document) unless it is overridden, if it is overridden, path expressions should point to that value rather than ROOT, which means "$a" is equivalent to "$$CURRENT.a".
This PR changes path expressions to be `CURRENT.path` rather than just `path`.
This hasn't been a problem since we don't support $let yet, however, now that we're adding expressions that can define variables, like `$map` this showed up on JS Tests.
### Does this PR have any customer impact?
### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes)
### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))
### Description
add jstest for self intersecting polygons
Related work items: #2894103
### 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
Related work items: #2019195
### 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
Lookup Index pushdown: Allow index pushdown of lookup queries for both left and right queries.
For _id joins, push to the B-tree index and use the object_id column.
For RUM indexes, introduce a new function and support that allows pushing to the index based on the specified path rather than the document itself.
This caused a customer $lookup query to go from taking 45+ mins and timing out to finishing in under 3 mins
### 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
### 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
### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))
1.16
### Description
Use st_dwithin and st_expand for $center
Related work items: #2894556
### 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))
### Description
Prep to do schema hotfix for colocation. Port to 1.13 / 1.14
### Does this PR have any customer impact?
No
### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
Code cleanup
### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes)
No
### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))
NA
### Description
Cleanup dead code
Related work items: #3059119
### 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
### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))
### Description
Fixes large buffer area bug where all the points of a shape are covered by the buffer area but the shape itself is not container, we were returning false positives in this case leading to failing geo_s2within_line_polygon_sphere.js.
With this we check for intersection with the compliment area in case the buffer area is greater than hemishpere of earth. If intersection is there that means the shape lies outside buffer area so we return false.
**Note:** this will also result in perf improvement for centerSphere radius greater than pi as in that case we just return true without any recheck.
Related work items: #2992082
### 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
adding support for $dateTrunc mongo operator
Related work items: #2019212
### 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
### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))
### Description
This PR addresses compatibility issues between $geoWithin and ST_Covers. It aims to fix some issues and outline others that are not easily resolved at the moment.
**Issue 1**: PostGIS uses a clockwise orientation rule for polygons, where exterior rings should be oriented clockwise and hole rings should be oriented counterclockwise. This is different from the GeoJSON standard specification, which is the opposite. Therefore, we need to ensure that all our polygons follow a clockwise orientation to be modeled correctly.
Few referrence where the difference is mention:
1- https://gis.stackexchange.com/questions/306567/postgis-geojson-query-not-validating#comment496061_306571
2- https://dev.to/rodreegez/geojson-right-hand-rule-2idk
**Solution**: This PR fixes the issue by forcing polygons to follow a clockwise orientation. This resolves some cases where a polygon sharing a boundary point is considered a match in ST_Covers. Without this fix, the same polygon or any shape sharing a boundary point would not be considered a match.
**Issue 2**: For a Multi*/Multi* GeoJSON type coverage, PostGIS expects a single component to cover all the components of the other GeoJSON, which is not the behavior in Mongo.
**Solution**: This PR fixes the issue by reading individual components from Multi*/GeometryCollection GeoJSON types and calling ST_Covers for each one individually. If all components are covered by the query, it is considered a match.
**Issue 3**: The coverage of polygons with holes is faulty in PostGIS, and there is no workaround for this issue. These limitations are documented and should throw not supported error for now until we fix this in pgmongo layer.
Mongo DB also has some undefined behaviors as they don't guarantee degeneracy https://www.mongodb.com/docs/manual/reference/operator/query/geoWithin/#degenerate-geometry, where the polygon doesn't guarantee to contain another polygon sharing its boundaries.
Also along with this PR the wkb iterator now follows a visitor patter in order to be reusable for other scenarios as well e.g. wkb traversing logic of $centerSphere is now also used for multi multi geowithin checks
Related work items: #2958169
### 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
Add inverseMatch aggregation stage
Currently it supports a spec like:
```
{ path: <path>, input: <doc or array of docs/path expression>, defaultResult: [optional | <bool> ]}
```
So if we want to fetch the input to the document query from an external collection, a lookup stage would need to be added prior to the inverseMatch.
The next stage of this feature is to support a spec like:
```
{ path: <path>, fromCollection: <coll>, pipelines: [$match/$project/$limit], defaultResult: [optional | <bool> ]}
```
### Does this PR have any customer impact?
No
### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
OSS
### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes)
Yes
### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))
N/A
### Description
Start bringing down the Public surface area with back compat for helio_api
### 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
### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))
N/A
### Description
- Add support for colocating tables in Postgres using the citus colocation mechanisms.
- Add support for modifying colocation with collMod
- Add support for querying shardCount and colocationId of tables in Mongo
Do this in a way that extends Helio using hooks.
### 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