Important
Helios features are now enabled during weekly update windows and are no longer directly tied to SingleStore engine releases. Refer to the release notes to view the latest features available in your Helios cluster.
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: