Snowpipe Streaming Node.js SDK v1.4.0
    Preparing search index...

    Class StreamingIngestChannel

    A channel for streaming data into a Snowflake table.

    A channel represents a logical stream of data into a single table through a pipe. Multiple channels can be opened on the same pipe for parallel ingestion. Each channel maintains its own offset token for exactly-once delivery guarantees.

    Create instances using client.openChannel().

    Index

    Properties

    binaryInputFormat: string

    The binary input format. One of: "BASE64", "HEX", "UTF-8".

    channelName: string

    The channel name.

    dbName: string

    The database name.

    isClosed: boolean

    Whether the channel is closed.

    pipeName: string

    The pipe name.

    schemaName: string

    The schema name.

    Methods

    • Append a single row into the channel.

      The row is an object with keys as column names and values as column values. Supported value types: null, undefined, boolean, number, string, BigInt, Buffer, Uint8Array, Date, Array, and Object.

      Parameters

      • row: Record<string, any>

        Row data as column-name to value pairs

      • OptionaloffsetToken: string

        Optional offset token, used to track the ingestion progress and replay ingestion in case of failures

      Returns Promise<void>

      StreamingIngestError If the row appending fails

    • Append multiple rows to the channel.

      Each row is an object with keys as column names and values as column values. Supported value types: null, undefined, boolean, number, string, BigInt, Buffer, Uint8Array, Date, Array, and Object.

      Parameters

      • rows: Record<string, any>[]

        Array of row objects (column-name to value pairs)

      • OptionalstartOffsetToken: string

        Optional start offset token of the batch

      • OptionalendOffsetToken: string

        Optional end offset token of the batch

      Returns Promise<void>

      TypeError If rows is not an array

      StreamingIngestError If the rows appending fails

    • Close the channel.

      Parameters

      • Optionaloptions: { drop?: boolean; timeoutMs?: number; waitForFlush?: boolean }

        Close options

        • Optionaldrop?: boolean

          Whether to drop the channel on the server, defaults to false.

        • OptionaltimeoutMs?: number

          Optional timeout in milliseconds for the flush operation.

        • OptionalwaitForFlush?: boolean

          Whether to wait for the flush to complete, defaults to true.

      Returns Promise<void>

      StreamingIngestError If closing the channel fails

    • Get the current status of this channel.

      Returns Promise<ChannelStatus>

      StreamingIngestError If getting the channel status fails

    • Get the latest committed offset token for this channel.

      Returns Promise<string>

      The latest committed offset token, or null if the channel is brand new

      StreamingIngestError If getting the latest committed offset token fails

    • Initiate a flush of all buffered data for this channel but do not wait for the flush to complete. Calls to appendRow/appendRows are still allowed on the channel after calling this method.

      Returns void

      StreamingIngestError If the flush cannot be initiated

    • Wait for a specific offset token to be committed.

      Snowflake commits offset tokens in batches, so the latest committed offset token may jump past the one you are waiting for. The tokenChecker should handle this case by doing a range check (greater than or equal) rather than an exact match.

      Parameters

      • tokenChecker: (token: string) => boolean

        A callable that receives the latest committed offset token (which may be null) and should return true when the wait condition is satisfied

      • Optionaloptions: { timeoutMs?: number }

        Wait options

        • OptionaltimeoutMs?: number

          Optional timeout in milliseconds.

      Returns Promise<void>

      StreamingIngestError If waiting for the commit fails

      Error If the timeout is reached

      TypeError If tokenChecker is not a function

      RangeError If timeoutMs is negative

    • Wait for all buffered data in this channel to be flushed to Snowflake.

      Parameters

      • Optionaloptions: { timeoutMs?: number }

        Wait options

        • OptionaltimeoutMs?: number

          Optional timeout in milliseconds.

      Returns Promise<void>

      StreamingIngestError If waiting for the flush fails

      Error If the timeout is reached