WriterClient

managedwriter. WriterClient

BigQuery Write API Client. The Write API can be used to write data to BigQuery.

This class provides the ability to make remote calls to the backing service through method calls that map to API methods.

For supplementary information about the Write API, see: https://cloud.google.com/bigquery/docs/write-api

Constructor

new WriterClient()

Methods

(async) batchCommitWriteStream(request) → {Promise}

Atomically commits a group of PENDING streams that belong to the same parent table.

Streams must be finalized before commit and cannot be committed multiple times. Once a stream is committed, data in the stream becomes available for read operations.

Parameters:
Name Type Description
request Object

The request object that will be sent.

Properties
Name Type Description
parent string

Required. Parent table that all the streams should belong to, in the form of projects/{project}/datasets/{dataset}/tables/{table}.

writeStreams Array.<string>

Required. The group of streams that will be committed atomically.

Returns:
Type Description
Promise

(async) createStreamConnection(requestopt, optionsopt) → {StreamConnection}

Open StreamConnection in which data can be appended to the given stream.

If a stream is created beforehand with createWriteStream, the streamId can be passed here.

Or destinationTable + streamType can be passed so the WriteStreamStream is created under the hood.

Parameters:
Name Type Attributes Description
request object <optional>
Properties
Name Type Attributes Description
streamId string <nullable>

Optional. The ID of the stream to open.

destinationTable string <nullable>

Optional. Parent table that all the streams should belong to, in the form of projects/{project}/datasets/{dataset}/tables/{table}.

streamType string <nullable>

Optional. The type of stream to create. If not specified, the default is DEFAULT.

options object <optional>

Call options. See CallOptions for more details.

Returns:
Type Description
StreamConnection
  • stream which rows can be appended to.

(async) createWriteStream(request) → {Promise.<string>}

Creates a write stream to the given table. Additionally, every table has a special stream named DefaultStream to which data can be written. This stream doesn't need to be created using createWriteStream. It is a stream that can be used simultaneously by any number of clients. Data written to this stream is considered committed as soon as an acknowledgement is received.

Parameters:
Name Type Description
request Object

The request object that will be sent.

Properties
Name Type Description
streamType string

Required. The type of stream to create.

destinationTable string

Required. Reference to the table to which the stream belongs, in the format of projects/{project}/datasets/{dataset}/tables/{table}.

Returns:
Type Description
Promise.<string>

} - The promise which resolves to the streamId.

(async) finalizeWriteStream(request) → {Promise.<FinalizeWriteStreamResponse>}

Finalize a write stream so that no new data can be appended to the stream. Finalize is not supported on the DefaultStream.

Parameters:
Name Type Description
request Object

The request object that will be sent.

Properties
Name Type Description
name string

Required. Name of the stream to finalize, in the form of projects/{project}/datasets/{dataset}/tables/{table}/streams/{stream}.

Returns:
Type Description
Promise.<FinalizeWriteStreamResponse>

(async) flushRows(request) → {Promise}

Flushes rows to a BUFFERED stream.

If users are appending rows to BUFFERED stream, flush operation is required in order for the rows to become available for reading. A Flush operation flushes up to any previously flushed offset in a BUFFERED stream, to the offset specified in the request.

Flush is not supported on the DEFAULT stream, since it is not BUFFERED.

Parameters:
Name Type Description
request Object

The request object that will be sent.

Properties
Name Type Description
writeStream string

Required. The stream that is the target of the flush operation.

offset google.protobuf.Int64Value

Ending offset of the flush operation. Rows before this offset(including this offset) will be flushed.

Returns:
Type Description
Promise

initialize() → {Promise}

Initialize the client. Performs asynchronous operations (such as authentication) and prepares the client. This function will be called automatically when any class method is called for the first time, but if you need to initialize it before calling an actual method, feel free to call initialize() directly.

You can await on this method if you want to make sure the client is initialized.

Returns:
Type Description
Promise

A promise that resolves when auth is complete.

isOpen()

Check if client is open and ready to send requests.