Constructor
new BigQueryWriteClient(optionsopt)
Construct an instance of BigQueryWriteClient.
Parameters:
Name | Type | Attributes | Description | ||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
<optional> |
The configuration object. The options accepted by the constructor are described in detail in this document. The common options are: Properties
|
Members
apiEndpoint
The DNS address for this API service - same as servicePath(), exists for compatibility reasons.
port
The port for this API service.
scopes
The scopes needed to make gRPC calls for every method defined in this service.
servicePath
The DNS address for this API service.
Methods
appendRows(optionsopt) → {Stream}
Appends data to the given stream.
If offset
is specified, the offset
is checked against the end of
stream. The server returns OUT_OF_RANGE
in AppendRowsResponse
if an
attempt is made to append to an offset beyond the current end of the stream
or ALREADY_EXISTS
if user provides an offset
that has already been
written to. User can retry with adjusted offset within the same RPC
connection. If offset
is not specified, append happens at the end of the
stream.
The response contains an optional offset at which the append happened. No offset information will be returned for appends to a default stream.
Responses are received in the same order in which requests are sent. There will be one response for each successful inserted request. Responses may optionally embed error information if the originating AppendRequest was not successfully processed.
The specifics of when successfully appended data is made visible to the table are governed by the type of stream:
-
For COMMITTED streams (which includes the default stream), data is visible immediately upon successful append.
-
For BUFFERED streams, data is made visible via a subsequent
FlushRows
rpc which advances a cursor to a newer offset in the stream. -
For PENDING streams, data is not made visible until the stream itself is finalized (via the
FinalizeWriteStream
rpc), and the stream is explicitly committed via theBatchCommitWriteStreams
rpc.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
options |
object |
<optional> |
Call options. See CallOptions for more details. |
Returns:
Type | Description |
---|---|
Stream |
An object stream which is both readable and writable. It accepts objects representing AppendRowsRequest for write() method, and will emit objects representing AppendRowsResponse on 'data' event asynchronously. Please see the documentation for more details and examples. |
Example
const stream = client.appendRows();
stream.on('data', (response) => { ... });
stream.on('end', () => { ... });
stream.write(request);
stream.end();
batchCommitWriteStreams(request, optionsopt) → {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 | Attributes | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
request |
Object |
The request object that will be sent. Properties
|
||||||||||
options |
object |
<optional> |
Call options. See CallOptions for more details. |
Returns:
Type | Description |
---|---|
Promise |
|
close() → {Promise}
Terminate the gRPC channel and close the client.
The client will no longer be usable and all future behavior is undefined.
Returns:
Type | Description |
---|---|
Promise |
A promise that resolves when the client is closed. |
createWriteStream(request, optionsopt) → {Promise}
Creates a write stream to the given table. Additionally, every table has a special stream named '_default' 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 | Attributes | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
request |
Object |
The request object that will be sent. Properties
|
||||||||||
options |
object |
<optional> |
Call options. See CallOptions for more details. |
Returns:
Type | Description |
---|---|
Promise |
|
finalizeWriteStream(request, optionsopt) → {Promise}
Finalize a write stream so that no new data can be appended to the stream. Finalize is not supported on the '_default' stream.
Parameters:
Name | Type | Attributes | Description | ||||||
---|---|---|---|---|---|---|---|---|---|
request |
Object |
The request object that will be sent. Properties
|
|||||||
options |
object |
<optional> |
Call options. See CallOptions for more details. |
Returns:
Type | Description |
---|---|
Promise |
|
flushRows(request, optionsopt) → {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 | Attributes | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
request |
Object |
The request object that will be sent. Properties
|
||||||||||
options |
object |
<optional> |
Call options. See CallOptions for more details. |
Returns:
Type | Description |
---|---|
Promise |
|
getProjectId() → {Promise}
Return the project ID used by this class.
Returns:
Type | Description |
---|---|
Promise |
A promise that resolves to string containing the project ID. |
getWriteStream(request, optionsopt) → {Promise}
Gets information about a write stream.
Parameters:
Name | Type | Attributes | Description | ||||||
---|---|---|---|---|---|---|---|---|---|
request |
Object |
The request object that will be sent. Properties
|
|||||||
options |
object |
<optional> |
Call options. See CallOptions for more details. |
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 to an authenticated service stub. |
matchDatasetFromTableName(tableName) → {string}
Parse the dataset from Table resource.
Parameters:
Name | Type | Description |
---|---|---|
tableName |
string |
A fully-qualified path representing Table resource. |
Returns:
Type | Description |
---|---|
string |
A string representing the dataset. |
matchDatasetFromWriteStreamName(writeStreamName) → {string}
Parse the dataset from WriteStream resource.
Parameters:
Name | Type | Description |
---|---|---|
writeStreamName |
string |
A fully-qualified path representing WriteStream resource. |
Returns:
Type | Description |
---|---|
string |
A string representing the dataset. |
matchLocationFromReadSessionName(readSessionName) → {string}
Parse the location from ReadSession resource.
Parameters:
Name | Type | Description |
---|---|---|
readSessionName |
string |
A fully-qualified path representing ReadSession resource. |
Returns:
Type | Description |
---|---|
string |
A string representing the location. |
matchLocationFromReadStreamName(readStreamName) → {string}
Parse the location from ReadStream resource.
Parameters:
Name | Type | Description |
---|---|---|
readStreamName |
string |
A fully-qualified path representing ReadStream resource. |
Returns:
Type | Description |
---|---|
string |
A string representing the location. |
matchProjectFromProjectName(projectName) → {string}
Parse the project from Project resource.
Parameters:
Name | Type | Description |
---|---|---|
projectName |
string |
A fully-qualified path representing Project resource. |
Returns:
Type | Description |
---|---|
string |
A string representing the project. |
matchProjectFromReadSessionName(readSessionName) → {string}
Parse the project from ReadSession resource.
Parameters:
Name | Type | Description |
---|---|---|
readSessionName |
string |
A fully-qualified path representing ReadSession resource. |
Returns:
Type | Description |
---|---|
string |
A string representing the project. |
matchProjectFromReadStreamName(readStreamName) → {string}
Parse the project from ReadStream resource.
Parameters:
Name | Type | Description |
---|---|---|
readStreamName |
string |
A fully-qualified path representing ReadStream resource. |
Returns:
Type | Description |
---|---|
string |
A string representing the project. |
matchProjectFromTableName(tableName) → {string}
Parse the project from Table resource.
Parameters:
Name | Type | Description |
---|---|---|
tableName |
string |
A fully-qualified path representing Table resource. |
Returns:
Type | Description |
---|---|
string |
A string representing the project. |
matchProjectFromWriteStreamName(writeStreamName) → {string}
Parse the project from WriteStream resource.
Parameters:
Name | Type | Description |
---|---|---|
writeStreamName |
string |
A fully-qualified path representing WriteStream resource. |
Returns:
Type | Description |
---|---|
string |
A string representing the project. |
matchSessionFromReadSessionName(readSessionName) → {string}
Parse the session from ReadSession resource.
Parameters:
Name | Type | Description |
---|---|---|
readSessionName |
string |
A fully-qualified path representing ReadSession resource. |
Returns:
Type | Description |
---|---|
string |
A string representing the session. |
matchSessionFromReadStreamName(readStreamName) → {string}
Parse the session from ReadStream resource.
Parameters:
Name | Type | Description |
---|---|---|
readStreamName |
string |
A fully-qualified path representing ReadStream resource. |
Returns:
Type | Description |
---|---|
string |
A string representing the session. |
matchStreamFromReadStreamName(readStreamName) → {string}
Parse the stream from ReadStream resource.
Parameters:
Name | Type | Description |
---|---|---|
readStreamName |
string |
A fully-qualified path representing ReadStream resource. |
Returns:
Type | Description |
---|---|
string |
A string representing the stream. |
matchStreamFromWriteStreamName(writeStreamName) → {string}
Parse the stream from WriteStream resource.
Parameters:
Name | Type | Description |
---|---|---|
writeStreamName |
string |
A fully-qualified path representing WriteStream resource. |
Returns:
Type | Description |
---|---|
string |
A string representing the stream. |
matchTableFromTableName(tableName) → {string}
Parse the table from Table resource.
Parameters:
Name | Type | Description |
---|---|---|
tableName |
string |
A fully-qualified path representing Table resource. |
Returns:
Type | Description |
---|---|
string |
A string representing the table. |
matchTableFromWriteStreamName(writeStreamName) → {string}
Parse the table from WriteStream resource.
Parameters:
Name | Type | Description |
---|---|---|
writeStreamName |
string |
A fully-qualified path representing WriteStream resource. |
Returns:
Type | Description |
---|---|
string |
A string representing the table. |
projectPath(project) → {string}
Return a fully-qualified project resource name string.
Parameters:
Name | Type | Description |
---|---|---|
project |
string |
Returns:
Type | Description |
---|---|
string |
Resource name string. |
readSessionPath(project, location, session) → {string}
Return a fully-qualified readSession resource name string.
Parameters:
Name | Type | Description |
---|---|---|
project |
string | |
location |
string | |
session |
string |
Returns:
Type | Description |
---|---|
string |
Resource name string. |
readStreamPath(project, location, session, stream) → {string}
Return a fully-qualified readStream resource name string.
Parameters:
Name | Type | Description |
---|---|---|
project |
string | |
location |
string | |
session |
string | |
stream |
string |
Returns:
Type | Description |
---|---|
string |
Resource name string. |
tablePath(project, dataset, table) → {string}
Return a fully-qualified table resource name string.
Parameters:
Name | Type | Description |
---|---|---|
project |
string | |
dataset |
string | |
table |
string |
Returns:
Type | Description |
---|---|
string |
Resource name string. |
writeStreamPath(project, dataset, table, stream) → {string}
Return a fully-qualified writeStream resource name string.
Parameters:
Name | Type | Description |
---|---|---|
project |
string | |
dataset |
string | |
table |
string | |
stream |
string |
Returns:
Type | Description |
---|---|
string |
Resource name string. |