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.
How it works
On each run, Elementary groups the table by the tested value and returns every value that appears more than once, together with the number of times it appears.- Failing rows are duplicated values. If the value
1042appears in three rows, it counts as one failing row with a duplicate count of 3. - Nulls are ignored. Rows where the value is null are never counted as duplicates. To require a value in every row, add a completeness test.
- The
whereclause applies before grouping. Only rows that match the condition are compared with each other.
Configuration
Severity, thresholds, sampled rows, and cadence work the same for all SQL data tests. See Configuration.
Examples
Example result
The sample lists each duplicated value and its count:
The failing-row count for this result is 2: two values are duplicated.
dbt equivalent
The dbtunique test checks the same rule from your dbt project. For a combination of columns, use an expression here, or dbt_utils.unique_combination_of_columns in dbt. See Cloud tests or dbt tests to decide which to use.
