---
title: "Smoke tests with set is not empty"
description: "The cheapest test there is — there is data where data should be — per table, per partition, per day; and how metadata-driven templates give every new table its smoke test for free"
url: "https://docs.justcat.it/how-to-guides/test-patterns/smoke-tests-with-set-is-not-empty/"
---
# Smoke tests with set is not empty


## The pattern

`set is not empty` passes on the first row and never reads a second. Make the query cheap to return one row — `TOP 1` / `LIMIT 1` and a filter that hits an index — and it is the fastest test in the project:


**Properties**



Name
: Customer dimension is loaded

Suite
: Smoke tests

Data source
: DWH

Query
: SELECT TOP 1 1 FROM dim.Customer

Expectation
: set is not empty





Name
: Yesterday's sales arrived

Suite
: Smoke tests

Data source
: DWH

Query
: SELECT TOP 1 1 FROM fact.Sales WHERE SaleDate = CAST(DATEADD(DAY, -1, GETDATE()) AS DATE)

Expectation
: set is not empty





Name
: Every region sold something this week

Suite
: Smoke tests

Data source
: DWH

Query
: ```sql
  SELECT TOP 1 1 FROM fact.Sales s JOIN dim.Store st ON st.StoreKey = s.StoreKey
  WHERE st.Region = 'EMEA' AND s.SaleDate >= DATEADD(DAY, -7, GETDATE())
  ```

Expectation
: set is not empty





**YAML**


```yaml
Tests:
- Name: Customer dimension is loaded
  Suite: Smoke tests
  Data source: DWH
  Query: SELECT TOP 1 1 FROM dim.Customer
  Expectation: set is not empty

- Name: Yesterday's sales arrived
  Suite: Smoke tests
  Data source: DWH
  Query: SELECT TOP 1 1 FROM fact.Sales WHERE SaleDate = CAST(DATEADD(DAY, -1, GETDATE()) AS DATE)
  Expectation: set is not empty

- Name: Every region sold something this week
  Suite: Smoke tests
  Data source: DWH
  Query: |
    SELECT TOP 1 1 FROM fact.Sales s JOIN dim.Store st ON st.StoreKey = s.StoreKey
    WHERE st.Region = 'EMEA' AND s.SaleDate >= DATEADD(DAY, -7, GETDATE())
  Expectation: set is not empty
```




Three grains: the table, the latest partition or period, a business slice. The middle one is the one that catches the load that did not run; run it first thing after every load and before the expensive comparisons — a run of `sets match` tests against an empty table fails loudly for the wrong reason.

Not `COUNT(*)`: a count always returns one row, so `set is not empty` would always pass — and the count costs a scan. See the warning on [Set is not empty](https://docs.justcat.it/reference/tests/expectations/set-is-not-empty/ "Set is not empty").

## Every table, without writing every test

A smoke test per table is the textbook case for a [template](https://docs.justcat.it/reference/tests/templates/ "Templates"): write it once for one table, point it at the catalog, and every table — including the one created next month — gets its test on the next open:


**Properties**


**Queries**


Name
: warehouse tables

Data source
: DWH

Query
: ```sql
  SELECT  TABLE_SCHEMA, TABLE_NAME
  FROM    INFORMATION_SCHEMA.TABLES
  WHERE   TABLE_TYPE = 'BASE TABLE' AND TABLE_SCHEMA IN ('dim', 'fact')
  ```




**Tests**


Name
: Table %TABLE_SCHEMA%.%TABLE_NAME% is not empty

Suite
: Smoke tests

Metadata
: warehouse tables

Data source
: DWH

Query
: SELECT TOP 1 1 FROM [%TABLE_SCHEMA%].[%TABLE_NAME%]

Expectation
: set is not empty





**YAML**


```yaml
Queries:
- Name: warehouse tables
  Data source: DWH
  Query: |
    SELECT  TABLE_SCHEMA, TABLE_NAME
    FROM    INFORMATION_SCHEMA.TABLES
    WHERE   TABLE_TYPE = 'BASE TABLE' AND TABLE_SCHEMA IN ('dim', 'fact')

Tests:
- Name: Table %TABLE_SCHEMA%.%TABLE_NAME% is not empty
  Suite: Smoke tests
  Metadata: warehouse tables
  Data source: DWH
  Query: SELECT TOP 1 1 FROM [%TABLE_SCHEMA%].[%TABLE_NAME%]
  Expectation: set is not empty
```




The same idea per partition (`sys.partitions`, a control table of loaded dates) or per customer. Tag the generated tests (`Tags: smoke`) and run the smoke suite alone with `--includeTags smoke` when you only want the quick answer — see [Run your tests](https://docs.justcat.it/how-to-guides/organize-and-run-tests/run-your-tests/ "Run your tests"). How templates work, and what happens when the catalog query returns nothing: [Generate tests from metadata](https://docs.justcat.it/how-to-guides/organize-and-run-tests/generate-tests-from-metadata/ "Generate tests from metadata").

## When "not empty" is not enough

A table with one stale row passes. Pair the smoke test with one of: a freshness check (`set is empty` on `MAX(LoadedAt) < …` — see [Find problems with set is empty](https://docs.justcat.it/how-to-guides/test-patterns/find-problems-with-set-is-empty/ "Find problems with set is empty")), a `set row count` where the count is known (five regions, twelve months), or a count comparison with the source — the first rung of [Compare data across systems](https://docs.justcat.it/how-to-guides/test-patterns/compare-data-across-systems/ "Compare data across systems").

## Related

* [Set is not empty](https://docs.justcat.it/reference/tests/expectations/set-is-not-empty/ "Set is not empty") · [Templates](https://docs.justcat.it/reference/tests/templates/ "Templates") — the reference.
* [Which expectation when](https://docs.justcat.it/how-to-guides/test-patterns/which-expectation-when/ "Which expectation when").

