calogica / dbt-expectations

Port(ish) of Great Expectations to dbt test macros
https://calogica.github.io/dbt-expectations/
Apache License 2.0
989 stars 120 forks source link

[BUG] expect_select_column_values_to_be_unique_within_record Doesn't Allow for Different Data Types #299

Closed bkimjin closed 4 months ago

bkimjin commented 4 months ago

Is this a new bug in dbt-expectations?

Current Behavior

When attempting to use this test for a string and a date column, it errors out on unpivot_columns because they are different data types.

Expected Behavior

The test should complete.

Steps To Reproduce

Add the following lines to a model in the yml file:

tests:
  - dbt_expectations.expect_select_column_values_to_be_unique_within_record:
    column_list: ["any_string_field", "any_date_field"]

Run dbt test

Relevant log output

Environment

- OS: MacOS
- Python: 3.10.12
- dbt: 1.6.9
- dbt-expectations: 0.10.1

Which database adapter are you using with dbt?

Note: dbt-expectations currently does not support database adapters other than the ones listed below.

Additional Context

This could be solved by wrapping the {{column}} in MD5:

select row_index, '{{ column }}' as column_name, {{ column }} as column_value from column_values

to:

select row_index, '{{ column }}' as column_name, md5({{ column }}) as column_value from column_values