Advertisement
AliaksandrLet

Спринт 4/12 → Тема 3/4: Проектирование и разработка проверки → Урок 5/11 → Задание 2

Jul 20th, 2023 (edited)
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.09 KB | None | 0 0
  1. from airflow.sensors.filesystem import FileSensor
  2. from datetime import datetime
  3. from airflow import DAG
  4. from airflow.sensors.filesystem import FileSensor
  5. from airflow.utils.task_group import TaskGroup
  6. from airflow.operators.sql import SQLCheckOperator, SQLValueCheckOperator
  7. from airflow.providers.postgres.hooks.postgres import PostgresHook
  8.  
  9. default_args = {
  10.     "start_date": datetime(2020, 1, 1),
  11.     "owner": "airflow"
  12. }
  13.  
  14. with DAG(
  15.     dag_id="Sprin4_Task1",
  16.     schedule_interval="@daily",
  17.     default_args=default_args,
  18.     catchup=False
  19.     ) as dag:
  20.  
  21.     order_log_value_check = SQLValueCheckOperator(
  22.         task_id='user_order_log_distinct_customer_check',
  23.         sql="select count(DISTINCT customer_id) from user_order_log",
  24.         pass_value=3,
  25.         tolerance=0.01
  26.     )
  27.  
  28.     activity_log_value_check = SQLValueCheckOperator(
  29.         task_id='user_activity_log_distinct_customer_check',
  30.         sql="select count(DISTINCT customer_id) from user_activity_log",
  31.         pass_value=3,
  32.         tolerance=0.01
  33.     )
  34.  
  35.     order_log_value_check >> activity_log_value_check
  36.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement