Rule types
Each check below lists its settings as the JSON the API stores. In the console you fill in the same settings in the Add rule form.
Row count
Section titled “Row count”Counts rows, optionally filtered. Catches empty loads, runaway duplicates and sudden drops.
| Setting | Meaning |
|---|---|
min_rows |
Fail below this many rows. |
max_rows |
Fail above this many rows. |
max_drop_percent |
Fail when the count drops more than this percentage (0–100) below the average of recent runs. |
lookback_runs |
How many recent runs make the average (1–100, default 7). |
filters |
Optional. |
Set at least one of min_rows, max_rows or max_drop_percent.
{ "min_rows": 1, "max_drop_percent": 50, "lookback_runs": 7 }Null check
Section titled “Null check”Measures the share of rows where a column is null.
| Setting | Meaning |
|---|---|
column |
The column to check. |
max_null_rate |
Highest allowed null rate, from 0 (never null) to 1. 0.05 means 5%. |
filters |
Optional. |
{ "column": "customer_id", "max_null_rate": 0 }Table freshness
Section titled “Table freshness”How long ago the table was last written, from metadata only (no scan).
| Setting | Meaning |
|---|---|
max_staleness_minutes |
Fail when the last write is older than this. |
{ "max_staleness_minutes": 1440 }- BigQuery reads the table’s last-modified time.
- PostgreSQL has no last-modified time, so DataLoris watches the table’s write counters: the first run only records a baseline, a write is noticed at the next run (precision = your schedule), and it needs the primary server. On a read replica the check ends in error. Details: PostgreSQL.
Column freshness
Section titled “Column freshness”How long ago the newest value of a timestamp column was, for example updated_at or event_time. Works on
replicas and catches pipelines that write but load nothing new.
| Setting | Meaning |
|---|---|
timestamp_column |
A timestamp or date column. |
max_staleness_minutes |
Fail when NOW() - MAX(timestamp_column) is longer than this. |
{ "timestamp_column": "updated_at", "max_staleness_minutes": 180 }Schema drift
Section titled “Schema drift”Compares the table’s columns, types and nullability with the previous run. No settings.
- Warning when columns are added.
- Failed when columns are removed, change type or change nullability.
- The first run records the baseline.
Unique
Section titled “Unique”Checks that no two rows share a key. The key is one column, or up to five for a composite key. Rows where any key column is null are ignored.
| Setting | Meaning |
|---|---|
columns |
1 to 5 columns that together must be unique. |
filters |
Optional. |
{ "columns": ["order_id"] }The measured value is the number of duplicate rows.
Allowed values
Section titled “Allowed values”Checks that every non-null value of a column is in a list you give, for example the values of a status
column.
| Setting | Meaning |
|---|---|
column |
The column to check. |
values |
1 to 100 allowed values, each at most 200 characters. Compared as text. |
filters |
Optional. |
{ "column": "status", "values": ["pending", "paid", "shipped", "cancelled"] }Only the count and rate of rows outside the list are stored, never the unexpected values themselves.
Custom SQL
Section titled “Custom SQL”Your own read-only query, which must return one number named violation_count. The rule fails when it is
greater than 0.
{ "sql": "SELECT COUNT(*) AS violation_count FROM public.orders WHERE total_amount < 0" }Rules and more examples: custom SQL.