Class managedwriter.WriterClient (4.2.1)

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

managedwriter

Package

@google-cloud/bigquery-storage

Constructors

(constructor)(opts)

constructor(opts?: ClientOptions);

Constructs a new instance of the WriterClient class

Parameter
NameDescription
opts ClientOptions

Properties

getClient

getClient: () => BigQueryWriteClient;

initialize

initialize: () => Promise<void>;

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.

setClient

setClient: (client: BigQueryWriteClient) => void;

Methods

batchCommitWriteStream(request)

batchCommitWriteStream(request: BatchCommitWriteStreamsRequest): Promise<BatchCommitWriteStreamsResponse>;

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.

Parameter
NameDescription
request BatchCommitWriteStreamsRequest

The request object that will be sent.

Returns
TypeDescription
Promise<BatchCommitWriteStreamsResponse>

{Promise} - a promise which resolves to an .

close()

close(): void;
Returns
TypeDescription
void

createStreamConnection(request, options)

createStreamConnection(request: {
        streamId?: string;
        destinationTable?: string;
        streamType?: WriteStreamType;
    }, options?: CallOptions): Promise<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
NameDescription
request { streamId?: string; destinationTable?: string; streamType?: WriteStreamType; }
options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Promise<StreamConnection>

{StreamConnection} - stream which rows can be appended to.

createWriteStream(request)

createWriteStream(request: {
        streamType: WriteStreamType;
        destinationTable: string;
    }): 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.

Parameter
NameDescription
request { streamType: WriteStreamType; destinationTable: string; }

The request object that will be sent.

Returns
TypeDescription
Promise<string>

{Promise

finalizeWriteStream(request)

finalizeWriteStream(request: FinalizeWriteStreamRequest): Promise<FinalizeWriteStreamResponse>;

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

Parameter
NameDescription
request FinalizeWriteStreamRequest

The request object that will be sent.

Returns
TypeDescription
Promise<FinalizeWriteStreamResponse_2>

{Promise

flushRows(request)

flushRows(request?: FlushRowsRequest): Promise<FlushRowsResponse>;

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.

Parameter
NameDescription
request FlushRowsRequest

The request object that will be sent.

Returns
TypeDescription
Promise<FlushRowsResponse_2>

{Promise} - The promise which resolves to a .

isOpen()

isOpen(): boolean;

Check if client is open and ready to send requests.

Returns
TypeDescription
boolean