예제 #1
0
 def _construct_operator(self, table, metric_thresholds, ratio_formula, ignore_zero):
     return IntervalCheckOperator(
         task_id="test_task",
         table=table,
         metrics_thresholds=metric_thresholds,
         ratio_formula=ratio_formula,
         ignore_zero=ignore_zero,
     )
예제 #2
0
         schedule_interval='0 8 * * *',
         start_date=datetime(2020, 1, 6)) as dag:
    enter_point = DummyOperator(task_id='enter_point')

    check_interaction_data = CheckOperator(
        task_id='check_interaction_data',
        sql=
        'SELECT COUNT(1) FROM interaction WHERE interaction_date = CURRENT_DATE',
        conn_id=CONN_ID)

    check_interaction_intervals = IntervalCheckOperator(
        task_id='check_interaction_intervals',
        table='interaction',
        metrics_thresholds={
            'COUNT(*)': 1.5,
            'MAX(amount)': 1.3,
            'MIN(amount)': 1.4,
            'SUM(amount)': 1.3
        },
        date_filter_column='interaction_date',
        days_back=5,
        conn_id=CONN_ID)

    check_interaction_amount_value = ValueCheckOperator(
        task_id='check_interaction_amount_value',
        sql=
        "SELECT COUNT(1) FROM interaction WHERE interaction_date=CURRENT_DATE - 1",
        pass_value=200,
        tolerance=0.2,
        conn_id=CONN_ID)

    check_unique_products_value = ValueCheckOperator(