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_ ARRAY_ PUSH
On this page
The BSON_ function adds the specified BSON value to the end of the input BSON array, and returns the array with the appended value as the result.
Syntax
BSON_ARRAY_PUSH(<array>, <value>)Arguments
-
<array>: A valid BSON array or an expression that evaluates to a BSON array. -
<value>: A BSON value to be appended to the input array.
Return Type
A BSON array.
Remarks
-
If
NULLis specified as the input array, it is considered as an empty BSON array. -
If
NULLis specified as the value to append, it is considered as the BSONNULLtype.
Examples
Note: The following examples explicitly cast string to BSON for clarity.
SELECT BSON_ARRAY_PUSH('[1, true, null, [7,8,9], "abc"]':>BSON, '{"a":{"b":9}}':>BSON):>JSON AS Result;
+-------------------------------------------+
| Result |
+-------------------------------------------+
| [1,true,null,[7,8,9],"abc",{"a":{"b":9}}] |
+-------------------------------------------+SELECT BSON_ARRAY_PUSH('[]':>BSON, '"abc"':>BSON):>JSON AS Result;
+---------+
| Result |
+---------+
| ["abc"] |
+---------+SELECT BSON_ARRAY_PUSH('[1,2,3,4]':>BSON, 'null':>BSON):>JSON AS Result;
+----------------+
| Result |
+----------------+
| [1,2,3,4,null] |
+----------------+Last modified: