SQLIntervalCheckOperator

Apache Airflow Certified

Checks that the values of metrics given as SQL expressions are within a certain tolerance of the ones from days_back before.

View on GitHub

Last Updated: May. 25, 2021

Access Instructions

Install the Apache Airflow provider package into your Airflow environment.

Import the module into your DAG file and instantiate it with your desired params.

Parameters

tableRequiredstrthe table name
days_backintnumber of days between ds and the ds we want to check against. Defaults to 7 days
ratio_formulastrwhich formula to use to compute the ratio between the two metrics. Assuming cur is the metric of today and ref is the metric to today - days_back. max_over_min: computes max(cur, ref) / min(cur, ref) relative_diff: computes abs(cur-ref) / ref Default: ‘max_over_min’
ignore_zeroboolwhether we should ignore zero metrics
metrics_thresholddicta dictionary of ratios indexed by metrics

Documentation

Checks that the values of metrics given as SQL expressions are within a certain tolerance of the ones from days_back before.

Note that this is an abstract class and get_db_hook needs to be defined. Whereas a get_db_hook is hook that gets a single record from an external source.

Was this page helpful?