BigQueryCreateExternalTableOperator

Google

Creates a new external table in the dataset with the data from Google Cloud Storage.

View Source

Last Updated: May. 7, 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

bucketstrThe bucket to point the external table to. (templated)
source_objectslistList of Google Cloud Storage URIs to point table to. If source_format is 'DATASTORE_BACKUP', the list must only contain a single URI.
destination_project_dataset_tablestrThe dotted (.). BigQuery table to load data into (templated). If is not included, project will be the project defined in the connection json.
schema_fieldslistIf set, the schema field list as defined here: https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs#configuration.load.schemaExample:schema_fields=[{"name": "emp_name", "type": "STRING", "mode": "REQUIRED"}, {"name": "salary", "type": "INTEGER", "mode": "NULLABLE"}]Should not be set when source_format is 'DATASTORE_BACKUP'.
table_resourceDict[str, Any]Table resource as described in documentation: https://cloud.google.com/bigquery/docs/reference/rest/v2/tables#Table If provided all other parameters are ignored. External schema from object will be resolved.
schema_objectstrIf set, a GCS object path pointing to a .json file that contains the schema for the table. (templated)
source_formatstrFile format of the data.
compressionstr[Optional] The compression type of the data source. Possible values include GZIP and NONE. The default value is NONE. This setting is ignored for Google Cloud Bigtable, Google Cloud Datastore backups and Avro formats.
skip_leading_rowsintNumber of rows to skip when loading from a CSV.
field_delimiterstrThe delimiter to use for the CSV.
max_bad_recordsintThe maximum number of bad records that BigQuery can ignore when running the job.
quote_characterstrThe value that is used to quote data sections in a CSV file.
allow_quoted_newlinesboolWhether to allow quoted newlines (true) or not (false).
allow_jagged_rowsboolAccept rows that are missing trailing optional columns. The missing values are treated as nulls. If false, records with missing trailing columns are treated as bad records, and if there are too many bad records, an invalid error is returned in the job result. Only applicable to CSV, ignored for other formats.
bigquery_conn_idstr(Optional) The connection ID used to connect to Google Cloud and interact with the Bigquery service.
google_cloud_storage_conn_idstr(Optional) The connection ID used to connect to Google Cloud and interact with the Google Cloud Storage service.
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.
src_fmt_configsdictconfigure optional fields specific to the source format
labelsdicta dictionary containing labels for the table, passed to BigQuery
encryption_configurationdict[Optional] Custom encryption configuration (e.g., Cloud KMS keys). Example:encryption_configuration = { "kmsKeyName": "projects/testp/locations/us/keyRings/test-kr/cryptoKeys/test-key" }
locationstrThe location used for the operation.
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

Creates a new external table in the dataset with the data from Google Cloud Storage.

The schema to be used for the BigQuery table may be specified in one of two ways. You may either directly pass the schema fields in, or you may point the operator to a Google Cloud Storage object name. The object in Google Cloud Storage must be a JSON file with the schema fields in it.

See also

For more information on how to use this operator, take a look at the guide: Create external table

Was this page helpful?