BaseSQLToGCSOperator

Google

Copy data from SQL to Google Cloud Storage in JSON or CSV format.

View on GitHub

Last Updated: Jun. 28, 2021

Access Instructions

Install the Google provider package into your Airflow environment.

Import the module into your DAG file and instantiate it with your desired params.

Parameters

sqlRequiredstrThe SQL to execute.
bucketRequiredstrThe bucket to upload to.
filenameRequiredstrThe filename to use as the object name when uploading to Google Cloud Storage. A {} should be specified in the filename to allow the operator to inject file numbers in cases where the file is split due to size.
schema_filenamestrIf set, the filename to use as the object name when uploading a .json file containing the BigQuery schema fields for the table that was dumped from the database.
approx_max_file_size_byteslongThis operator supports the ability to split large table dumps into multiple files (see notes in the filename param docs above). This param allows developers to specify the file size of the splits. Check https://cloud.google.com/storage/quotas to see the maximum allowed file size for a single object.
export_formatstrDesired format of files to be exported.
field_delimiterstrThe delimiter to be used for CSV files.
null_markerstrThe null marker to be used for CSV files.
gzipboolOption to compress file for upload (does not apply to schemas).
schemastr or listThe schema to use, if any. Should be a list of dict or a str. Pass a string if using Jinja template, otherwise, pass a list of dict. Examples could be seen: https://cloud.google.com/bigquery/docs /schemas#specifying_a_json_schema_file
gcp_conn_idstr(Optional) The connection ID used to connect to Google Cloud.
google_cloud_storage_conn_idstr(Deprecated) The connection ID used to connect to Google Cloud. This parameter has been deprecated. You should pass the gcp_conn_id parameter instead.
delegate_tostrThe account to impersonate using domain-wide delegation of authority, if any. For this to work, the service account making the request must have domain-wide delegation enabled.
parametersdicta parameters dict that is substituted at query runtime.
impersonation_chainUnion[str, Sequence[str]]Optional service account to impersonate using short-term credentials, or chained list of accounts required to get the access_token of the last account in the list, which will be impersonated in the request. If set as a string, the account must grant the originating account the Service Account Token Creator IAM role. If set as a sequence, the identities from the list must grant Service Account Token Creator IAM role to the directly preceding identity, with first account from the list granting this role to the originating account (templated).

Documentation

Copy data from SQL to Google Cloud Storage in JSON or CSV format.

Was this page helpful?