Skip to content

Commit

Permalink
add boolean and boolean metrics (#118)
Browse files Browse the repository at this point in the history
* add boolean and boolean metrics

* Updated other adapter-specific macros

---------

Co-authored-by: David Zajac <83138279+davidzajac1@users.noreply.github.com>
  • Loading branch information
suelai and davidzajac1 authored Nov 23, 2023
1 parent b3db48b commit 2f8ce22
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 11 deletions.
24 changes: 24 additions & 0 deletions macros/metrics/base/build_in/column_default.sql
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,28 @@
{{ percentage_formula(re_data_metric_missing_count(context), re_data_metric_row_count()) }}
{% endmacro %}

{% macro re_data_metric_count_true(context) %}
COALESCE(
SUM(
CASE
WHEN {{ context.column_name }} IS TRUE THEN 1
ELSE 0
END
),
0
)
{% endmacro %}

{% macro re_data_metric_count_false(context) %}
COALESCE(
SUM(
CASE
WHEN {{ context.column_name }} IS FALSE THEN 1
ELSE 0
END
),
0
)
{% endmacro %}


24 changes: 13 additions & 11 deletions macros/utils/column_types.sql
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
'enum',
] %}
{{ return('numeric') }}

{% elif column.data_type in [ 'boolean', 'bool' ] %}

{{ return('boolean') }}

{% else %}
{{ return('unknown') }}
Expand Down Expand Up @@ -68,6 +72,10 @@

{{ return('numeric') }}

{% elif column.data_type in [ 'BOOLEAN' ] %}

{{ return('boolean') }}

{% else %}

{{ return('unknown') }}
Expand All @@ -78,23 +86,17 @@


{% macro bigquery__get_column_type(column) %}

{% if column.data_type in [
'STRING'
] %}

{% if column.data_type in [ 'STRING' ] %}
{{ return('text') }}

{% elif column.data_type in [
"INT64", "NUMERIC", "BIGNUMERIC", "FLOAT64", "INTEGER"]
%}

{% elif column.data_type in [ "INT64", "NUMERIC", "BIGNUMERIC", "FLOAT64", "INTEGER"] %}
{{ return('numeric') }}

{% elif column.data_type in [ "BOOLEAN", "BOOL"] %}
{{ return('boolean') }}
{% else %}

{{ return('unknown') }}

{% endif %}

{% endmacro %}
{% endmacro %}

0 comments on commit 2f8ce22

Please sign in to comment.