BSON_INPUT_STREAM_TO_ARRAY

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. Similarly, the output is cast to JSON.

  • Convert a BSON array:

    SELECT table_col:>JSON AS Result
    FROM 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 Result
    FROM 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 Result
    FROM 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: July 10, 2025

Was this article helpful?

Verification instructions

Note: You must install cosign to verify the authenticity of the SingleStore file.

Use the following steps to verify the authenticity of singlestoredb-server, singlestoredb-toolbox, singlestoredb-studio, and singlestore-client SingleStore files that have been downloaded.

You may perform the following steps on any computer that can run cosign, such as the main deployment host of the cluster.

  1. (Optional) Run the following command to view the associated signature files.

    curl undefined
  2. Download the signature file from the SingleStore release server.

    • Option 1: Click the Download Signature button next to the SingleStore file.

    • Option 2: Copy and paste the following URL into the address bar of your browser and save the signature file.

    • Option 3: Run the following command to download the signature file.

      curl -O undefined
  3. After the signature file has been downloaded, run the following command to verify the authenticity of the SingleStore file.

    echo -n undefined |
    cosign verify-blob --certificate-oidc-issuer https://oidc.eks.us-east-1.amazonaws.com/id/CCDCDBA1379A5596AB5B2E46DCA385BC \
    --certificate-identity https://kubernetes.io/namespaces/freya-production/serviceaccounts/job-worker \
    --bundle undefined \
    --new-bundle-format -
    Verified OK