2
votes

How to set table expiration using BigQueryOperator in Airflow when a table is created using query. We can update the tables expiration with another BigQueryOperator , but looking for doing the create and setting expiration together.

1
Do you want to set an expiration time on the table or on the partitions? - guillaume blaquiere

1 Answers

2
votes

Use a DDL statement in your SQL, like so:

CREATE TABLE
  dataset.foo OPTIONS( expiration_timestamp=TIMESTAMP "2020-01-01 00:00:00 UTC",
    description="A table created from SQL with a expiration set" ) AS
SELECT
  'foo' AS col_1