Добавить dags/mat_view_refresh.py
This commit is contained in:
parent
afeeab1f21
commit
119632aea6
|
|
@ -0,0 +1,21 @@
|
||||||
|
from airflow import DAG
|
||||||
|
from airflow.providers.postgres.operators.postgres import PostgresOperator
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
|
VIEWS = [
|
||||||
|
"sells_and_statuses_v",
|
||||||
|
]
|
||||||
|
|
||||||
|
with DAG(
|
||||||
|
dag_id="refresh_multiple_matviews",
|
||||||
|
start_date=datetime(2024, 1, 1),
|
||||||
|
schedule_interval="0 7 * * *",
|
||||||
|
catchup=False,
|
||||||
|
):
|
||||||
|
|
||||||
|
for view in VIEWS:
|
||||||
|
PostgresOperator(
|
||||||
|
task_id=f"refresh_{view.replace('.', '_')}",
|
||||||
|
postgres_conn_id="postgres_default",
|
||||||
|
sql=f"REFRESH MATERIALIZED VIEW {view};",
|
||||||
|
)
|
||||||
Loading…
Reference in New Issue