Important
New database features are no longer connected to engine versions; features are now enabled independently during scheduled update windows, and “major” and “minor” releases no longer exist in Helios. Please visit the release notes to view the latest features available in your database clusters.
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: