0
votes

From GCP docs: https://cloud.google.com/bigquery/docs/views their instructions for creating a view using the BQ API is "Call the tables.insert method with a table resource that contains a view property."

Any idea how to do this via airflow's BigQueryOperator? Or is there another operator I should us?

2

2 Answers

2
votes

Just use DDL's CREATE VIEW statement as

{CREATE VIEW | CREATE VIEW IF NOT EXISTS | CREATE OR REPLACE VIEW}
view_name
[OPTIONS(view_option_list)]
AS query_expression
2
votes

View creation using BigQueryOperator has been implemented but not in any releases yet. So you could either follow Mikhail Berlyant's suggestion or use the latest BigQueryOperator code from the Airflow's master branch.

Reference: https://github.com/apache/airflow/blob/77eb492b9cf279071d6123e4f0064363ed2b47b3/airflow/gcp/operators/bigquery.py#L727