Is this a new bug in dbt-expectations?
Current Behavior
The test expect_column_proportion_of_unique_values_to_be_between fails with empty tables (mostly used in CI runs) with division by zero.
Expected Behavior
Should return 1 (all values are unique because there are no values)
Steps To Reproduce
run the test in a table with zero rows.
Which database adapter are you using with dbt?
BigQuery
Additional Context
I think a simple fix can be implemented here with no breaking changes, using ANSI SQL:
case
when count({{ column_name }}) = 0 then 1 -- Return 1 when division by zero
else cast(count(distinct {{ column_name }}) as {{ dbt.type_float() }})/count({{ column_name }})
end
I did in this PR #20
Is this a new bug in dbt-expectations?
Current Behavior
The test
expect_column_proportion_of_unique_values_to_be_betweenfails with empty tables (mostly used in CI runs) with division by zero.Expected Behavior
Should return 1 (all values are unique because there are no values)
Steps To Reproduce
run the test in a table with zero rows.
Which database adapter are you using with dbt?
BigQuery
Additional Context
I think a simple fix can be implemented here with no breaking changes, using ANSI SQL:
I did in this PR #20