Suela Isaj
11/06/2023, 8:34 AMIdan Shavit
11/06/2023, 9:21 AMSuela Isaj
11/06/2023, 9:42 AMelementary, and we have had re_data before, so the syntax below is related to that specific framework. I have this macro that calculates the fraction of users that are found day by day, basically ensuring that the users we see today have an overlap with the ones before.
What I would like is the flexibility to have a general metric that I can use in different tables.
{% macro re_data_metric_frac_requiring_user_day_by_day(context) %}
with
relevant_data as (
select
{{ context.time_filter }} as time_filter,
{{ context.column_name }} as id,
from {{ context.table_name }}
where
date({{ context.time_filter }})
> date_sub(current_date(), interval 3 day)
)
select countif(old_data.id is not null) / if(count(*) = 0, 1, count(*))
from {{ context.table_name }} new_data
left join
relevant_data old_data
on new_data.{{ context.column_name }} = old_data.id
and timestamp_diff(
new_data.{{ context.time_filter }}, old_data.time_filter, hour
)
between 14 and 30
where {{ in_time_window(context.time_filter) }}
{% endmacro %}
If you have a similar example, let me know, we don't have to go into detail about the metric above. I am basically looking for a way to define a macro or maybe a test that I can call in 6 different tables as an elementary metricSuela Isaj
11/06/2023, 2:21 PMnon_null_percent metric for column anomalies, which doesn't seem to be part of out-of-the-box metrics https://docs.elementary-data.com/guides/anomaly-detection-tests/column-anomalies, how should I configure that?Idan Shavit
11/06/2023, 4:08 PMnull_precent test - if there is an anomaly in the null_precent (too many or too less), that means you have an anomaly at the not null precent (too less or too many).
2. Create a view over the table which replaces nulls with a value and values with null, and use the null_precent test over itSuela Isaj
11/07/2023, 8:44 AMnon_null_percent to catch the real anomalies. I can try to lower the anomaly sensitivity for now for the null_percent.
Any plans to support custom metrics in the future? I would be very interested!Idan Shavit
11/07/2023, 11:52 AM