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

[Refactor]not_null_proportion_multiple_columns #832

Merged
merged 3 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 0 additions & 71 deletions tests/generic/custom_null_proportion_multiple_columns.sql

This file was deleted.

19 changes: 11 additions & 8 deletions tests/generic/not_null_proportion_multiple_columns.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% test not_null_proportion_multiple_columns(model, at_least=0.05) %}
{% test not_null_proportion_multiple_columns(model, ignore_values="", at_least=0.05) %}

{%- set columns = adapter.get_columns_in_relation(model) -%}
{% set suffix = "_nulls" %}
Expand Down Expand Up @@ -28,8 +28,7 @@
*
from pivot_columns
where
quantity / total_records > (1 - {{ at_least }})

quantity / total_records > (1 - {{ at_least }}) and column_name not in ('{{ ignore_values | join("', '") }}')

)
select * from faulty_columns
Expand All @@ -41,16 +40,20 @@
) -%}
{% if errors["column_name"] != () %}
{% for e in errors["column_name"] | unique %}

{% set proc_err = (
errors["quantity"][loop.index0]
/ errors["total_records"][loop.index0]
) * 100 %}

{{
log(
"LOG: Coluna com preenchimento menor que "
~ at_least * 100
~ "% ---> "
~ e
~ " [FAIL]",
"Coluna: " ~ e ~ " - Preenchimento de: " ~ "%0.2f"
| format(proc_err | float) ~ "% - Resultado: FAIL",
info=True,
)
}}

select '{{e}}' as column
{% if not loop.last %}
union all
Expand Down
Loading