Duplicate count
This example validator counts the number of occurrences for a specific column with a window and sums the total count. The resulting value represents the number of duplicates for that particular value.SQL (BigQuery)
Referential integrity
Cross-asset dependency check. This example validator computes how many non-NULL values exist in a foreign key table which is not present in the primary key table. See also Tumbling Reference Count for another cross-asset example, and Assessing Cross-Asset Dependencies for the broader pattern.SQL (BigQuery)
Global row count
This example validator uses a global window to count the total number of records in the table. No template functions are needed since the full table will be scanned during each poll. The only requirement is that the query must return thevalidio_metric column.
SQL (BigQuery)
Segmented tumbling row count
This example validator is configured with a tumbling window on the fieldcreated_at and a segmentation on the field country. The SQL query uses the window template functions to calculate the number of records per country and window. The query must return the validio_metric, validio_window, and country columns.
SQL (BigQuery)
Segmented tumbling mean ratio
This example validator is configured with a tumbling window on the fieldcreated_at and a segmentation on the field city. The SQL query uses the window template functions to calculate the mean ratio by comparing the mean of amount in the current window against the two previous windows. The query must return the validio_metric, validio_window, and city columns.
SQL (BigQuery)
Tumbling reference count
Cross-asset dependency check. This example validator compares the number of records in two tables using hourly tumbling windows. See also Referential Integrity for another cross-asset example, and Assessing Cross-Asset Dependencies for the broader pattern.SQL (BigQuery)
Duration between records
This example validator is configured with an hourly tumbling window oncreated_at and calculates the maximum duration in seconds between the records timestamp in each window.
SQL (BigQuery)
Exponentially weighted moving average
This validator computes a 14-day exponentially weighted moving average (EWMA) over the specified metric field (revenue in this example). The validator is configured to use a tumbling window on the Date timestamp.SQL (BigQuery)
- Metric Field - Replace revenue with the desired metric field.
- Window Length - Adjust the number of windows over which the moving average is calculated (the example shown uses 14 days). For an X-window moving average, set the reference_window_filter function to include X-1 past windows to capture the current window as part of the calculation.
- Timestamp Field - Replace Date with the relevant timestamp field for the metric.
Trend alert
This validator detects significant drifts in a metric over time. It compares the current value of the metric with its value seen previously Y period ago (for example, 30 days when Y=30 for daily windows) and triggers an alert if the change exceeds X%. The recipe uses theLAG function to compare the current metric value with its value from the previous Y past window. It calculates the percentage change and returns 1 if the change is above a specified threshold of X%.
SQL (BigQuery)
- Metric Field - Replace the metric field (for example, Sales, Profit) to track trends.
- Timestamp Field - Replace Date with the relevant timestamp field for the metric.
- Y - Adjust the Y parameter to define the number of past windows for comparison.
Numeric anomaly
This validator identifies anomalies in numeric data by counting the number of datapoints, within a given window, that deviate from expected values. The validator uses a reference source to define the acceptable range of values as (ref_mean ± 1/precision * ref_std). Higher precision means that the accepted range of values is narrower, which identifies more anomalies. Conversely, lower precision values imply a wider range of accepted values, which identifies fewer anomalies.
The recipe uses the REF_WIN_LEN parameter to define number of windows in the reference source and the OFFSET_WIN_LEN parameter to define number of offset windows from current window. For more information. Refer to Reference Source Validation.
SQL (BigQuery)
- Metric Field - Replace the
metricfield with your relevant field. - Timestamp Field - Replace
timestampwith the relevant timestamp field. - Adjust the
REF_WIN_LENandOFFSET_WIN_LENparameters to define the number of past windows included in the reference calculations. - Adjust the
precisionparameter to control the width of acceptable range of values. - Combine this Custom SQL validator with a Dynamic Threshold to alert on deviation of datapoints from the reference source.