Find training runs that were never evaluated with a LEFT JOIN anti-join
Why it matters Anti-joins find missing work everywhere: runs without evals, users without a first prompt, documents without embeddings.
Before a model review you want every finished training run to have an eval. The runs that are missing one are the to-do list.
Write query() returning a SQLite SQL string. Tables: runs(run_id INTEGER, name TEXT) and evals(eval_id INTEGER, run_id INTEGER, score REAL). An eval row counts even if its score is NULL. evals.run_id can be NULL for orphan rows logged by a broken job.
Return (run_id, name) for every run that has no row in evals. Order by run_id ascending.
def query()Example
runs (1, 'base'), (2, 'lr-up'), (3, 'long'); evals (10, 1, 0.7), (11, 3, NULL) give [(2, 'lr-up')].
Understand the idea
An anti-join returns rows of one table that have NO match in another. The trick is a LEFT JOIN: every left row stays, and when no right row matches, the right side columns are NULL. Keep only those NULL rows.
Worked example: runs 1, 2, 3 and evals for runs 1 and 3. After the LEFT JOIN, run 2 has eval_id NULL, so it is the only row kept.
Rule: SELECT a.* FROM a LEFT JOIN b ON b.key = a.key WHERE b.pk IS NULL. Check a column that is never NULL on a real match, such as b's primary key. NOT EXISTS is a safe alternative; NOT IN is not, because comparing with NULL gives unknown and x NOT IN (1, NULL) is never true.
Pipelines use this to find documents missing embeddings or runs missing evals.