Добавить dags/mat_view_refresh.py

This commit is contained in:
bn_user 2026-07-23 06:47:31 +00:00
parent afeeab1f21
commit 119632aea6
1 changed files with 21 additions and 0 deletions

21
dags/mat_view_refresh.py Normal file
View File

@ -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};",
)