You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
dbt_utils.unique_combination_of_columns test produces false failures testing for uniqueness of col_a and col_b in a model in Redshift consisting of only these two columns. While this error shows up when running the dbt_utils.unique_combination_of_columns test I get the same false failures when I run the complied test code directly in Redshift.
Steps to reproduce
I was unable to reproduce this error with an example model. I can only describe the scenario that I am seeing.
I have the following model:
Column | Type | Collation | Nullable | Default Value
---------------------------+-----------------------+----------------+----------+---------------
col_a | character varying(20) | case_sensitive | YES |
col_b | character(4) | case_sensitive | YES |
select
count(*) as failures,
count(*) != 0 as should_warn,
count(*) != 0 as should_error
from (
with validation_errors as (
select
col_a, col_b
from schema.model_name
group by col_a, col_b
having count(*) > 1
)
select *
from validation_errors
) dbt_internal_test
Expected results
I would expect no test errors. When checking the model for duplicates using sql or when using dbt core functionality to test for uniqueness I get no failing records.
The following test results in no failing records:
- name: model_name
data_tests:
- unique:
column_name: "(col_a|| '-' || col_b)"
```
### Actual results
I get 805 test errors, which would be the number of test errors if I had omitted col_b from the dbt_utils.unique_combination_of_columns and only tested for uniqueness of col_a
When I run the inner query of the compiled test code directly in Redshift:
```
with validation_errors as (
select
col_a, col_b
from schema.model_name
group by col_a, col_b
having count(*) > 1
)
select *
from validation_errors
```
I get the following result:
```
col_a | col_b
-------+------
(0 rows)
```
The result of the total query in Redshift is as follows:
```
failures | should_warn | should_error
----------+-------------+--------------
805 | t | t
```
### System information
**The contents of your `packages.yml` file:**
**Which database are you using dbt with?**
- [ ] postgres
- [x] redshift
- [ ] bigquery
- [ ] snowflake
- [ ] other (specify: ____________)
**The output of `dbt --version`:**
```
Core:
- installed: 1.8.8
- latest: 1.9.1 - Update available!
Your version of dbt-core is out of date!
You can find instructions for upgrading here:
https://docs.getdbt.com/docs/installation
Plugins:
- postgres: 1.8.2 - Update available!
- redshift: 1.8.1 - Update available!
At least one plugin is out of date or incompatible with dbt-core.
You can find instructions for upgrading here:
https://docs.getdbt.com/docs/installation
```
### Are you interested in contributing the fix?
Depends on what issue this can be tracked down to
The text was updated successfully, but these errors were encountered:
Describe the bug
dbt_utils.unique_combination_of_columns test produces false failures testing for uniqueness of col_a and col_b in a model in Redshift consisting of only these two columns. While this error shows up when running the dbt_utils.unique_combination_of_columns test I get the same false failures when I run the complied test code directly in Redshift.
Steps to reproduce
I was unable to reproduce this error with an example model. I can only describe the scenario that I am seeing.
I have the following model:
I run the following test:
The compiled code looks like this:
Expected results
I would expect no test errors. When checking the model for duplicates using sql or when using dbt core functionality to test for uniqueness I get no failing records.
The following test results in no failing records:
The text was updated successfully, but these errors were encountered: