Open camerondavison opened 2 months ago
dbt_utils.not_null_proportion is returning 0 in clickhouse because it is not using floats for the division
select sum(case when baz is null then 0 else 1 end) / cast(count(*) as numeric) as not_null_proportion from `foo`.`bar`
which is basically
select 100/cast(200 as numeric)
returns 0 in clickhouse
.5
0
Which database are you using dbt with?
The output of dbt --version:
dbt --version
Core: - installed: 1.8.6 - latest: 1.8.6 - Up to date! Plugins: - clickhouse: 1.8.3
I think that the fix could just be to sum by 1.0 and 0.0 instead of 1 and 0 which should be the same across database, and just tells dbs to use float math correctly.
select 100.0/cast(200 as numeric)
works as expected
Describe the bug
dbt_utils.not_null_proportion is returning 0 in clickhouse because it is not using floats for the division
Steps to reproduce
which is basically
returns 0 in clickhouse
Expected results
.5
Actual results
0
Which database are you using dbt with?
The output of
dbt --version
:I think that the fix could just be to sum by 1.0 and 0.0 instead of 1 and 0 which should be the same across database, and just tells dbs to use float math correctly.
works as expected