Decision 02 of 05 · 2 min read
Checks decide what gets published
How does a query that runs still get rejected?
SQL that runs can still answer the wrong question: a join at the wrong grain double-counts, the wrong statuses get counted, or a month outside the data reads as zero. Before any number reaches the reader, the pipeline runs three kinds of check and applies one coverage rule.
| Check or rule | What it compares | What it stops |
|---|---|---|
| integrity | Order-item and product IDs are present and unique | Duplicate or missing keys that would inflate or drop totals |
| status exclusion | The eligible counts against the metric's status rules | Cancelled, returned or status-less items counted as sales |
| reconciliation | Each result against an independent system query | A group figure that differs from the independent recomputation, or groups that don't add up to the overall total |
| coverage (a rule, not a check) | The requested period against the data's declared coverage | A month outside the data shown as 0: it comes back unavailable, a partly covered one is marked partial, and a covered category with no eligible items is a real 0 |
If any check fails, Trellis gives no answer and names the failed check. A recorded answer's evidence also lists the SQL guard, which every query passes before it runs (decision 3). The development tests include a deliberately wrong join that runs cleanly; the checks reject it.
The trade-off
More queries per answer: a by-category answer runs six. On sample-sized data that costs fractions of a cent; at warehouse scale the reconciliation strategy would need a cost review.
What was shown
- OfflineA failed integrity, status or reconciliation check means no answer, with the failed check named. A deliberately wrong join that runs cleanly is caught.
- StagingA month outside the data's declared coverage comes back unavailable, not 0; a partly covered period is marked partial. Within coverage, a category with no eligible items is a real 0.
- StagingFor every run checked, the rows, SQL, checks and source on screen matched the stored answer exactly.