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_ INPUT_ STREAM_ TO_ ARRAY
On this page
The BSON_ function converts a BSON array of documents or concatenated BSON documents to a PSQL Array.
Syntax
BSON_INPUT_STREAM_TO_ARRAY(<input>)Arguments
-
input: A valid BSON array, an expression that evaluates to a valid BSON array, or concatenated BSON documents.
Return Type
A PSQL array.
Examples
Note: The following examples explicitly cast string to BSON for clarity.
-
Convert a BSON array:
SELECT table_col:>JSON AS ResultFROM TABLE(BSON_INPUT_STREAM_TO_ARRAY('[{"a":1},{"b":2},{"c":3},{"d":4}]':>BSON));+---------+ | Result | +---------+ | {"a":1} | | {"b":2} | | {"c":3} | | {"d":4} | +---------+SELECT table_col:>JSON AS ResultFROM TABLE(BSON_INPUT_STREAM_TO_ARRAY('[{"a":1,"b":"abcdef","c":null},{"b":2,"e":{"f":{"g":[]}}},{"c":3},{}]':>JSON:>BSON));+-------------------------------+ | Result | +-------------------------------+ | {"a":1,"b":"abcdef","c":null} | | {"b":2,"e":{"f":{"g":[]}}} | | {"c":3} | | {} | +-------------------------------+ -
Convert concatenated documents:
SELECT table_col:>JSON AS ResultFROM TABLE(BSON_INPUT_STREAM_TO_ARRAY(x'0C00000010610001000000000C00000010620002000000000C00000010630003000000000C0000001064000400000000'))AS Result;+---------+ | Result | +---------+ | {"a":1} | | {"b":2} | | {"c":3} | | {"d":4} | +---------+where,
x'0C00000010610001000000000C00000010620002000000000C00000010630003000000000C0000001064000400000000'is a hex literal that is formed by concatenating the following BSON documents:Document
Hex Representation
{"a":1}0C0000001061000100000000{"b":2}0C0000001062000200000000{"c":3}0C0000001063000300000000{"d":4}0C0000001064000400000000
Last modified: