Skip to content

Commit 90935a9

Browse files
authored
Adding ability to install re_data for Greenplum database (#102)
1 parent e92a334 commit 90935a9

3 files changed

Lines changed: 11 additions & 8 deletions

File tree

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{% macro postgres_type_db() %}
2+
{{ ('postgres', 'greenplum') }}
3+
{% endmacro %}

macros/utils/json/to_single_json.sql

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{% macro to_json_string_value_or_null(column) %}
22
(
33
case
4-
when {{column}} is null then 'null'
4+
when {{ column }} is null then 'null'
55
else '"' ||
66
regexp_replace(
7-
replace(cast({{column}} as {{string_type()}}), '"', {{escape_seq_for_json('"') }}),
8-
'\n', {{ quote_new_line() }} {% if target.type == 'postgres' %}, 'g' {% endif %}
7+
replace(cast({{ column }} as {{ string_type() }}), '"', {{ escape_seq_for_json('"') }}),
8+
'\n', {{ quote_new_line() }} {% if target.type in postgres_type_db() %}, 'g' {% endif %}
99
) || '"'
1010
end
1111
)
@@ -19,4 +19,4 @@
1919
{%- if not loop.last %} || ',' || {%- endif %}
2020
{%- endfor %}
2121
|| '}'
22-
{% endmacro %}
22+
{% endmacro %}

models/metrics/for_anomalies/re_data_last_stats.sql

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ with median_value as (
66
column_name,
77
metric,
88
interval_length_sec,
9-
avg(value) {% if target.type != 'postgres' %} over(partition by {{ columns_to_group_by }}) {% endif %} as last_avg,
9+
avg(value) {% if target.type not in postgres_type_db() %} over(partition by {{ columns_to_group_by }}) {% endif %} as last_avg,
1010
{{ percentile(percentile_field='value', partition_field=columns_to_group_by, percent='0.25') }} as last_first_quartile,
1111
{{ percentile(percentile_field='value', partition_field=columns_to_group_by, percent='0.5') }} as last_median,
1212
{{ percentile(percentile_field='value', partition_field=columns_to_group_by, percent='0.75') }} as last_third_quartile
@@ -15,7 +15,7 @@ with median_value as (
1515
where
1616
time_window_end > {{- anamaly_detection_time_window_start() -}} and
1717
time_window_end <= {{- time_window_end() -}}
18-
{% if target.type == 'postgres' %}
18+
{% if target.type in postgres_type_db() %}
1919
group by
2020
{{ columns_to_group_by }}
2121
{% endif %}
@@ -46,11 +46,11 @@ with median_value as (
4646
column_name,
4747
metric,
4848
interval_length_sec,
49-
avg(absolute_deviation_from_mean) {% if target.type != 'postgres' %} over(partition by {{ columns_to_group_by }}) {% endif %} as mean_absolute_deviation,
49+
avg(absolute_deviation_from_mean) {% if target.type not in postgres_type_db() %} over(partition by {{ columns_to_group_by }}) {% endif %} as mean_absolute_deviation,
5050
{{ percentile(percentile_field='absolute_deviation_from_median', partition_field=columns_to_group_by, percent='0.5') }} as median_absolute_deviation
5151
from
5252
abs_deviation
53-
{% if target.type == 'postgres' %}
53+
{% if target.type in postgres_type_db() %}
5454
group by
5555
{{ columns_to_group_by }}
5656
{% endif %}

0 commit comments

Comments
 (0)