Class managedwriter.JSONWriter (4.5.0)

A StreamWriter that can write JSON data to BigQuery tables. The JSONWriter is built on top of a Writer, and it simply converts all JSON data to protobuf messages then calls Writer's appendRows() method to write to BigQuery tables. It maintains all Writer functions, but also provides an additional feature: schema update support, where if the BigQuery table schema is updated, users will be able to ingest data on the new schema after some time (in order of minutes).

managedwriter.Writer managedwriter

Package

@google-cloud/bigquery-storage

Constructors

(constructor)(params)

constructor(params: WriterOptions);

Creates a new JSONWriter instance.

Parameter
NameDescription
params WriterOptions

The parameters for the JSONWriter. See WriterOptions docs for more information.

Methods

appendRows(rows, offsetValue)

appendRows(rows: JSONList, offsetValue?: IInt64Value['value']): PendingWrite;

Writes a JSONList that contains objects to be written to the BigQuery table by first converting the JSON data to protobuf messages, then using Writer's appendRows() to write the data at current end of stream. If there is a schema update, the current Writer is closed and reopened with the updated schema.

Parameters
NameDescription
rows JSONList

The list of JSON rows.

offsetValue IInt64Value_3['value']

? - The offset value.

Returns
TypeDescription
PendingWrite

{managedwriter.PendingWrite} The pending write.

close()

close(): void;
Returns
TypeDescription
void

setDefaultMissingValueInterpretation(defaultMissingValueInterpretation)

setDefaultMissingValueInterpretation(defaultMissingValueInterpretation: MissingValueInterpretation): void;

Update how missing values are interpreted for the given stream.

Parameter
NameDescription
defaultMissingValueInterpretation MissingValueInterpretation
Returns
TypeDescription
void

setMissingValueInterpretations(missingValueInterpretations)

setMissingValueInterpretations(missingValueInterpretations: MissingValueInterpretationMap): void;

Update how missing values are interpreted for individual columns.

Parameter
NameDescription
missingValueInterpretations MissingValueInterpretationMap
Returns
TypeDescription
void

setProtoDescriptor(protoDescriptor)

setProtoDescriptor(protoDescriptor: IDescriptorProto): void;

Update the proto descriptor for the Writer. Internally a reconnection event is gonna happen to apply the new proto descriptor.

Parameter
NameDescription
protoDescriptor IDescriptorProto

The proto descriptor.

Returns
TypeDescription
void