Skip to content

Commit 2f8ce22

Browse files
suelaidavidzajac1
andauthored
add boolean and boolean metrics (#118)
* add boolean and boolean metrics * Updated other adapter-specific macros --------- Co-authored-by: David Zajac <83138279+davidzajac1@users.noreply.github.com>
1 parent b3db48b commit 2f8ce22

2 files changed

Lines changed: 37 additions & 11 deletions

File tree

macros/metrics/base/build_in/column_default.sql

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,28 @@
6464
{{ percentage_formula(re_data_metric_missing_count(context), re_data_metric_row_count()) }}
6565
{% endmacro %}
6666

67+
{% macro re_data_metric_count_true(context) %}
68+
COALESCE(
69+
SUM(
70+
CASE
71+
WHEN {{ context.column_name }} IS TRUE THEN 1
72+
ELSE 0
73+
END
74+
),
75+
0
76+
)
77+
{% endmacro %}
78+
79+
{% macro re_data_metric_count_false(context) %}
80+
COALESCE(
81+
SUM(
82+
CASE
83+
WHEN {{ context.column_name }} IS FALSE THEN 1
84+
ELSE 0
85+
END
86+
),
87+
0
88+
)
89+
{% endmacro %}
90+
6791

macros/utils/column_types.sql

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@
2727
'enum',
2828
] %}
2929
{{ return('numeric') }}
30+
31+
{% elif column.data_type in [ 'boolean', 'bool' ] %}
32+
33+
{{ return('boolean') }}
3034

3135
{% else %}
3236
{{ return('unknown') }}
@@ -68,6 +72,10 @@
6872

6973
{{ return('numeric') }}
7074

75+
{% elif column.data_type in [ 'BOOLEAN' ] %}
76+
77+
{{ return('boolean') }}
78+
7179
{% else %}
7280

7381
{{ return('unknown') }}
@@ -78,23 +86,17 @@
7886

7987

8088
{% macro bigquery__get_column_type(column) %}
81-
82-
{% if column.data_type in [
83-
'STRING'
84-
] %}
8589

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

88-
{% elif column.data_type in [
89-
"INT64", "NUMERIC", "BIGNUMERIC", "FLOAT64", "INTEGER"]
90-
%}
91-
93+
{% elif column.data_type in [ "INT64", "NUMERIC", "BIGNUMERIC", "FLOAT64", "INTEGER"] %}
9294
{{ return('numeric') }}
9395

96+
{% elif column.data_type in [ "BOOLEAN", "BOOL"] %}
97+
{{ return('boolean') }}
9498
{% else %}
95-
9699
{{ return('unknown') }}
97100

98101
{% endif %}
99-
100-
{% endmacro %}
102+
{% endmacro %}

0 commit comments

Comments
 (0)