---
title: "SQL tables with no assertion | Metacenta"
description: "For SQL projects without dbt: which written tables and views have no assertion file, why that matters, and how to add a first check beside a query."
url: "https://metacenta.com/rules/sql-relation-untested"
updated: "2026-10-14"
tokens: 633
---

Testing · rule sql-relation-untested

# SQL tables with no assertion

A Metacenta review checks this under the rule **Written relations have an assertion**. Everything below applies whether or not you ever commission one.

## What this rule checks

For SQL projects without dbt, this rule flags each table or view the SQL writes that has no assertion file beside it. An assertion file is a `checks.sql`, `tests.sql` or `assertions.sql`, or any file under a `tests/` folder. A view that only passes a table through is covered by that table's assertions.

## Why it matters

Without an assertion, a duplicate row or a missing day reaches every reader before anyone notices. When no relation in the project has one, we report it once for the whole project rather than once per table.

## How to fix it

**Add assertions to the relations people read.** Start with the relations people read most. Add a `checks.sql` beside the query that asserts the grain and the keys, in the same style your tested relations already use.

Before:

```sql
-- orders/query.sql
create or replace table analytics.orders as
select order_id, customer_id, ordered_at
from raw.shop_orders;
```

After:

```sql
-- orders/checks.sql: each query should return no rows
select order_id
from analytics.orders
group by order_id
having count(*) > 1;

select order_id
from analytics.orders
where order_id is null or customer_id is null;
```

## When it is fine to leave

A scratch table nobody reads needs no assertion. A relation checked somewhere we cannot see, such as warehouse constraints or a separate test repository, is covered in practice. Tell us, and the finding comes out of your report.

## What we need to check it

The `.sql` files, read from your repository with read-only access or uploaded. We match assertion files to relations by name and path, so the finding is medium confidence.

[Ask about a review](https://metacenta.com/enquire?src=rule-sql-relation-untested&via=md)

## Related pages

- [dbt models with no tests](https://metacenta.com/rules/model-untested)
- [dbt unique_combination_of_columns: how to use it](https://metacenta.com/rules/model-grain-not-asserted)
- [dbt key columns: no not_null test](https://metacenta.com/rules/model-no-not-null-test)
- [Dagster asset checks: how to set them up](https://metacenta.com/rules/dagster-asset-unchecked)
- [A sample review, as a client reads it](https://metacenta.com/sample)
- [All published rules](https://metacenta.com/rules)
- [How a review is assessed](https://metacenta.com/standard)
