BigQueryDest
class BigQueryDest(
conn: BigQueryConn,
tables: TableSpec = None,
if_table_exists: IfTableExistStrategySpec = 'append',
schema_strategy: SchemaStrategySpec = 'update',
)
Bases: DestinationPlugin
Categories: destination
Destination plugin to store data in BigQuery tables. The data is first stored in parquet files in a GCS bucket, and then loaded into the BigQuery tables.
Initializes the BigQueryDest with the configuration desired to store the data.
Parameters
connBigQueryConnThe BigQuery connection configuration.
tablesstr | list[str] | None, optionalThe table(s) to store the data in. If multiple tables are provided, they must be provided as a list. If None, the table names will be those of the input tables for the function. Defaults to None.
if_table_exists\{'append', 'replace'\}, optionalThe strategy to follow when the table already exists. - ‘append’ will append to an existing table. - ‘replace’ will create a new table, overwriting an existing one. Defaults to 'append'.
schema_strategy\{'update', 'strict'\}, optionalThe strategy to follow for the schema when the table already exists. - ‘update’ will update the schema with the possible new columns that might exist in the TableFrame. - ‘strict’ will not modify the schema, and will fail if there is any difference. Defaults to 'update'.
Properties
connBigQueryConnif_table_existsIfTableExistStrategySpecstr: The strategy to follow when the table already exists.
schema_strategySchemaStrategySpecstr: The strategy to follow when appending to a table with an existing schema.
tableslist[str] | NoneMethods
streamdef stream(working_dir: str, *results: list[LazyFrame | None] | LazyFrame | None)
Trigger the exporting of the data. This method will receive the resulting data from the user function and must store it in the desired location. Note: this method might materialize the data provided in a single chunk generated by the chunk function if invoked, so chunks should be of an appropriate size.
Parameters:
working_dirstrThe folder where any intermediate files generated must be stored (this refers to temporary files that will be deleted after the execution of the plugin, not the final destination of the data)
resultsThe data to be exported. It is a list of polars LazyFrames or None.
Returns:
None