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_operator
    # Create BigQuery output dataset.
    make_bq_dataset = bash_operator.BashOperator(
        # Executing 'bq' command requires Google Cloud SDK which comes
        # preinstalled in Cloud Composer.
        bash_command='bq ls {} || bq mk {}'.format(
            bq_dataset_name, bq_dataset_name))

What's next

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