mirror of
https://github.com/FerretDB/documentdb.git
synced 2026-11-25 19:59:54 -05:00
### 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, yes ### ChangeLog (Refer [Template](../oss/CHANGELOG.md)) ### Description Support sorting with collation. We define new custom sort operators which compare operands using applicable collation string. `<<<` is for ascending order. `>>>` is for descending order. Example: `SELECT * from <collection> ORDER BY <value> USING <<<` This will further be used for partitioning, grouping, and related comparisons. ---- #### AI description (iteration 1) #### PR Classification New feature: Support for collation in sort operations. #### PR Summary This pull request adds support for collation in sort operations within the database engine. - `src/test/regress/expected/bson_dollar_ops_collation_tests_runtime.out`: Added multiple test cases to verify collation behavior with various sort and order by operations, including case sensitivity and numeric ordering. <!-- GitOpsUserAgent=GitOps.Apps.Server.pullrequestcopilot --> Related work items: #4014123
56 lines
2.1 KiB
SQL
56 lines
2.1 KiB
SQL
CREATE OR REPLACE FUNCTION __API_CATALOG_SCHEMA__.bson_orderby(__CORE_SCHEMA__.bson, __CORE_SCHEMA__.bson)
|
|
RETURNS __CORE_SCHEMA__.bson
|
|
LANGUAGE c
|
|
IMMUTABLE PARALLEL SAFE STRICT
|
|
AS 'MODULE_PATHNAME', $function$command_bson_orderby$function$;
|
|
|
|
|
|
CREATE OR REPLACE FUNCTION __API_SCHEMA_INTERNAL_V2__.bson_orderby(document __CORE_SCHEMA__.bson, filter __CORE_SCHEMA__.bson, collationString text)
|
|
RETURNS __CORE_SCHEMA__.bson
|
|
LANGUAGE c
|
|
IMMUTABLE PARALLEL SAFE STRICT
|
|
AS 'MODULE_PATHNAME', $function$command_bson_orderby$function$;
|
|
|
|
|
|
-- ORDER BY operator function for $setWindowFields
|
|
CREATE OR REPLACE FUNCTION __API_SCHEMA_INTERNAL_V2__.bson_orderby_partition(__CORE_SCHEMA__.bson, __CORE_SCHEMA__.bson, boolean)
|
|
RETURNS __CORE_SCHEMA__.bson
|
|
LANGUAGE c
|
|
IMMUTABLE PARALLEL SAFE STRICT
|
|
AS 'MODULE_PATHNAME', $function$bson_orderby_partition$function$;
|
|
|
|
|
|
CREATE OR REPLACE FUNCTION __API_SCHEMA_INTERNAL_V2__.bson_orderby_partition(document __CORE_SCHEMA__.bson, filter __CORE_SCHEMA__.bson, isTimeRangeWindow boolean, collationString text)
|
|
RETURNS __CORE_SCHEMA__.bson
|
|
LANGUAGE c
|
|
IMMUTABLE PARALLEL SAFE STRICT
|
|
AS 'MODULE_PATHNAME', $function$bson_orderby_partition$function$;
|
|
|
|
|
|
CREATE OR REPLACE FUNCTION __API_SCHEMA_INTERNAL_V2__.bson_orderby_compare(__CORE_SCHEMA__.bson, __CORE_SCHEMA__.bson)
|
|
RETURNS int
|
|
LANGUAGE c
|
|
IMMUTABLE PARALLEL SAFE STRICT
|
|
AS 'MODULE_PATHNAME', $function$bson_orderby_compare$function$;
|
|
|
|
|
|
CREATE OR REPLACE FUNCTION __API_SCHEMA_INTERNAL_V2__.bson_orderby_lt(__CORE_SCHEMA__.bson, __CORE_SCHEMA__.bson)
|
|
RETURNS bool
|
|
LANGUAGE c
|
|
IMMUTABLE PARALLEL SAFE STRICT
|
|
AS 'MODULE_PATHNAME', $function$bson_orderby_lt$function$;
|
|
|
|
|
|
CREATE OR REPLACE FUNCTION __API_SCHEMA_INTERNAL_V2__.bson_orderby_eq(__CORE_SCHEMA__.bson, __CORE_SCHEMA__.bson)
|
|
RETURNS bool
|
|
LANGUAGE c
|
|
IMMUTABLE PARALLEL SAFE STRICT
|
|
AS 'MODULE_PATHNAME', $function$bson_orderby_eq$function$;
|
|
|
|
|
|
CREATE OR REPLACE FUNCTION __API_SCHEMA_INTERNAL_V2__.bson_orderby_gt(__CORE_SCHEMA__.bson, __CORE_SCHEMA__.bson)
|
|
RETURNS bool
|
|
LANGUAGE c
|
|
IMMUTABLE PARALLEL SAFE STRICT
|
|
AS 'MODULE_PATHNAME', $function$bson_orderby_gt$function$;
|