Skip to main content
SQL data tests are built-in checks for the most common data quality rules. You choose a table, a column or expression, and the rule to enforce. Elementary generates the SQL for your warehouse, runs it on a schedule, and reports the rows that break the rule. They are cloud tests: you create and manage them in the Elementary UI, they run outside your dbt pipeline, and they don’t need a pull request or a dbt project. They work on any supported table in the environment, including tables that aren’t part of a dbt project.
SQL-based cloud tests read table data, so they need data access for the environment’s warehouse connection. Data access is enabled in one of two ways:
  • Elementary enables data access on the warehouse connection. Contact the Elementary team to turn it on.
  • You connect an Elementary Runtime to the warehouse connection.
Until data access is available, these tests are hidden from the test catalog.

Test types

Results count toward the data quality dimension shown for each test type.
For a rule that none of these types can express, such as a calculation or a check across several tables, use a custom SQL test.

How it works

The saved configuration is the test. On every run, Elementary generates the query for your warehouse from that configuration, runs it, and counts the failing rows. Improvements to the generated SQL apply to existing tests without editing them. Each run:
  1. Scans the entire table, filtered by the optional where clause.
  2. Counts the failing rows and stores a sample of them with the result.
  3. Sets the result to Pass, Warning, Failure, or Error based on the test’s severity and thresholds.
  4. Stores the exact query that ran with the result, so any past result can be reproduced.
Results appear with your other tests in test results, incidents, alerts, the Catalog, and test coverage.
SQL data tests read table data and use compute in your data warehouse. Every run scans the full table. On large tables, add a where clause to limit the scanned data and pick a schedule that matches how often the data changes. The preview shows the table size each run will scan.

Where the queries run

Elementary runs these queries in one of two ways, depending on how the environment’s warehouse connection is set up: With Elementary Runtime, Elementary Cloud still prepares the SQL, schedules the test, and manages results and incidents, but the runtime validates and executes the query inside your network. When a runtime reports a warehouse connection as healthy, Elementary sends all test runs and previews for that connection through the runtime instead of connecting directly. The runtime also enforces its own local limits for query time, concurrency, and result size, and can limit or disable row samples entirely. See Local limits and What leaves your network.
Use a dedicated, read-only warehouse role for these tests, whichever way they run. It only needs to read the tables your tests query. See Database roles for examples per warehouse.

Create a SQL data test

1

Start a new test

Go to Test Configuration, click Add test, and choose Table test or Column test. You can also start from an asset in the Catalog.
2

Choose the table and the test type

Select one table. SQL data tests are added to one table at a time. In the test picker, filter on Elementary cloud and choose Uniqueness, Completeness, Validity, or Relationship.
Add test page with the Elementary cloud source filter selected, showing the Uniqueness, Completeness, Validity, and Relationship test cards

SQL data tests in the test picker, with the Elementary cloud source filter selected

3

Configure the test

Choose the Tested field, either a column or a SQL expression, and fill in the fields of the test type. Optionally add a where clause.
4

Set severity, sampled rows, and cadence

Choose the severity and optional thresholds, how many failing rows to store with each result, and the test cadence. Add owners, tags, and a description.
5

Run the test

Click Run test in the Preview section to run the test against your warehouse. The preview shows the result status, the number of failed rows, a sample of them, and the size of the table each run will scan. You must run the preview after your last change before you can save the test.
6

Save

Submit the test. No pull request is required. Elementary runs the test right away and then on its schedule.
You can also ask the Elementary AI agent to recommend and create SQL data tests. The agent previews each test before it proposes the plan, and you review the plan before anything is created. The MCP server provides the same create and preview tools.

Configuration

These settings are shared by all SQL data test types. Each test type page lists its own fields. Expressions and where clauses must be a single expression. They can’t contain subqueries, aggregate or window functions, *, or table-qualified column names such as t.amount. Scheduled runs time out after 5 minutes and return an Error result. Previews time out after 30 seconds.

Scheduling

Set the Test cadence to one of:
  • Every N hours, from 1 to 23
  • Daily at a time of day
  • Weekly on a day and time
  • Custom, with a cron expression
Times are in your account’s timezone. Tests can’t run more often than every 15 minutes.

Results

Every row the test returns is a failing row. Elementary compares the number of failing rows to the test’s Severity setting: A run that can’t complete, for example because the query timed out, a column no longer exists, or the warehouse role lacks permissions, gets the Error status with the reason. The test stays enabled and runs again on its next schedule. Each result shows the failing-row count and, when available, a sample of the failing rows.

Edit or delete a test

Open the test from test results or an incident and go to the Configuration tab to change its settings. The test type can’t be changed. Saving re-runs the test with the new configuration. To delete tests, select them on the Test Configuration page and use the delete option, or open a test result and click ... → Delete test. Every create, edit, and delete is recorded in the audit logs.

Alerts

SQL data test failures map to the Cloud data tests category in alert rules. In environments with data access, the category is selected by default on new rules and included in the default rule. Check existing rules if you want them to include SQL data test failures.

Supported warehouses

SQL data tests run on tables and other materialized assets in:
  • Snowflake
  • Databricks
  • Redshift
  • Postgres
Ephemeral models and assets without a table in the warehouse can’t be tested.

SQL data tests or dbt tests

Each SQL data test has a dbt equivalent. If your environment has both data access and a dbt project, see Cloud tests or dbt tests to choose where each check should live.