Files
Vinod Sridharan 5289ac451b Merged PR 1758714: [Reverse Order] Schema changes to support reverse index order
### 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
### ChangeLog (Refer [Template](../oss/CHANGELOG.md))

### Description
Add schema mappings to support reverse order against the index
This requires us to have a reverse order by operator and associated sort support.

This registers the order by functions - the implementation wil be flushed out in a separate change.

This is due to the fact that amorderbyop only supports order by forwards when added with index recheck.

Index Recheck is required in our case since orderby on the index is lossy. To overcome this, we introduce a forward walk index operator and a reverse walk index operator as 2 separate operators that can be pushed to the index.

----
#### AI description  (iteration 1)
#### PR Classification
This pull request implements a new reverse ordering feature through API changes and database schema updates.

#### PR Summary
The changes introduce reverse order functionality for BSON queries by adding new C functions and corresponding SQL deployment scripts.
- `pg_documentdb/src/query/bson_dollar_operators.c` adds `command_bson_orderby_reverse` and `bson_orderby_compare_sort_support` functions with appropriate PG function registrations.
- SQL files under `/oss/pg_documentdb/sql/udfs/` and `/oss/pg_documentdb/sql/operators/` provide new UDFs and operators (including a reverse order operator and btree comparator support) to enable the feature.
- Expected API schema files in both `/oss/pg_documentdb/src/test/regress/expected/` and `/pgmongo/src/test/regress/expected/` are updated to include the new functions.
<!-- GitOpsUserAgent=GitOps.Apps.Server.pullrequestcopilot -->
2025-08-07 11:14:08 +08:00
..