Use the BashOperator to run the BigQuery bq command

Use the BashOperator in an Apache Airflow DAG to call the BigQuery bq command.

Documentation pages that include this code sample

To view the code sample used in context, see the following documentation:

Code sample


from airflow.operators import bash
    # Create BigQuery output dataset.
    make_bq_dataset = bash.BashOperator(
        # Executing 'bq' command requires Google Cloud SDK which comes
        # preinstalled in Cloud Composer.
        bash_command=f'bq ls {bq_dataset_name} || bq mk {bq_dataset_name}')

What's next

To search and filter code samples for other Google Cloud products, see the Google Cloud sample browser