Important
The SingleStore 9.1 release candidate (RC) is available now. It will be promoted to general availability (GA) soon and at that time it will be renamed to SingleStore 10.
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, while SingleStore 9.0 is recommended for production workloads.
BSON_ LENGTH
On this page
The BSON_ function returns the number of keys present in the BSON object or array.
Syntax
BSON_LENGTH(<value>)Argument
<value>: A valid BSON object or array, or an expression that evaluates to a valid BSON object or array.
Return Type
A number.
Remarks
Returns NULL if the input value is one of the following:
-
An invalid BSON type
-
A BSON type other than a document or an array
-
A
NULL
Examples
Note: The following examples explicitly cast string to BSON for clarity.
SELECT BSON_LENGTH('{"a":1, "b":2, "c":"abc"}':>BSON) AS Length;
+--------+
| Length |
+--------+
| 3 |
+--------+SELECT BSON_LENGTH('[1, true, null, [7,8,9], "abc"]':>BSON) AS Length;
+--------+
| Length |
+--------+
| 5 |
+--------+SELECT BSON_LENGTH('null':>BSON) AS Length;
+--------+
| Length |
+--------+
| NULL |
+--------+Last modified: