Important
Self-managed SingleStore will soon transition from version 9.1 RC to version 10. This new semantic versioning scheme will provide SingleStore with finer control over engine and feature releases that were not possible with the current versioning scheme.
In the interim, SingleStore 9.1 RC can be used to preview, evaluate, and provide feedback on the new and upcoming features in SingleStore 10 prior to its general availability. Ahead of this transition, SingleStore 9.0 is recommended for production workloads, which can later be upgraded to SingleStore 10.
BSON_ NORMALIZE_ *
On this page
The BSON_ function is a set of four BSON functions that normalize BSON documents and allows you to perform the following operations with improved performance:
-
Cross-type comparison for numeric types.
-
Compare across multiple data types, as defined in Comparison/Sort Order.
-
Build indexes using normalized computed columns.
-
Sort and hash BSON documents.
The BSON_ function includes the following BSON functions:
-
BSON_: Normalizes the BSON document for equality comparisons (such asNORMALIZE() $eq). -
BSON_: Normalizes the BSON document for ascending sort or less than comparisons, (such asNORMALIZE_ ASC() $lt).For arrays, the smallest element is selected. -
BSON_: Normalizes the BSON document for descending sort or greater than comparisons, (such asNORMALIZE_ DESC() $gt).For arrays, the largest element is selected. -
BSON_: Similar toNORMALIZE_ NO_ ARRAY() BSON_, it normalizes the BSON document for equality comparisons (such asNORMALIZE() $eq), but returns an error if the BSON document contains an array at any level.
Syntax
BSON_NORMALIZE(<bson_input>)
BSON_NORMALIZE_ASC(<bson_input>)
BSON_NORMALIZE_DESC(<bson_input>)
BSON_NORMALIZE_NO_ARRAY(<bson_input>)Argument
<bson_: A valid BSON document or an expression that evaluates to a valid BSON document.
Examples
Note: The following example explicitly casts a string to BSON for clarity.
SELECT BSON_NORMALIZE('0':>BSON) = BSON_NORMALIZE('{"$numberDouble":"0"}':>BSON) AS Result;
+--------+
| Result |
+--------+
| 1 |
+--------+Last modified: