Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dbt_utils.not_null_proportion does not work with clickhouse #952

Open
1 of 5 tasks
camerondavison opened this issue Sep 20, 2024 · 0 comments
Open
1 of 5 tasks

dbt_utils.not_null_proportion does not work with clickhouse #952

camerondavison opened this issue Sep 20, 2024 · 0 comments
Labels
bug Something isn't working triage

Comments

@camerondavison
Copy link

camerondavison commented Sep 20, 2024

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

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

Expected results

.5

Actual results

0

Which database are you using dbt with?

  • postgres
  • redshift
  • bigquery
  • snowflake
  • other (specify: clickhouse)

The output of 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

@camerondavison camerondavison added bug Something isn't working triage labels Sep 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage
Projects
None yet
Development

No branches or pull requests

1 participant