Skip to content

Optimizer

SQL batch query optimizer.

SQL query optimizer: batches multiple checks into a single query.

Instead of running N separate queries

SELECT COUNT(*) FROM t WHERE col IS NULL; SELECT COUNT(DISTINCT col) FROM t; SELECT MIN(col), MAX(col) FROM t;

The optimizer compiles them into one

SELECT SUM(CASE WHEN col IS NULL THEN 1 ELSE 0 END) as col_null_count, COUNT(DISTINCT col) as col_distinct_count, MIN(col) as col_min, MAX(col) as col_max, COUNT(*) as _total FROM t;

BatchedMetric(alias, expression, check_config) dataclass

A single SQL expression to include in the batched query.

BatchPlan(table, metrics=list(), non_batchable=list()) dataclass

Plan for a batched query against a single table.

plan_batch(table, checks)

Create a batch plan from a list of checks.

build_batch_query(plan)

Build a single SQL query from a batch plan.

execute_batch(connection, plan)

Execute a batched query and interpret results into CheckResults.