From 0f73b709428a4bfc84dfdd5fd97f83c568064b94 Mon Sep 17 00:00:00 2001 From: uri Date: Fri, 6 Sep 2024 09:13:27 +0200 Subject: [PATCH] Adding new column test: latest_date_is_yesterday --- macros/tests/latest_date_is_yesterday.sql | 13 +++++++++++++ models/reporting/general/schema.yaml | 4 +++- 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 macros/tests/latest_date_is_yesterday.sql diff --git a/macros/tests/latest_date_is_yesterday.sql b/macros/tests/latest_date_is_yesterday.sql new file mode 100644 index 0000000..3ae166f --- /dev/null +++ b/macros/tests/latest_date_is_yesterday.sql @@ -0,0 +1,13 @@ +{% test latest_date_is_yesterday(model, column_name) %} + + with + model_max_date as ( + select max({{ column_name }}) as max_date + from {{ model }} + ) + + select * + from model_max_date + where max_date <> current_date - 1 + +{% endtest %} diff --git a/models/reporting/general/schema.yaml b/models/reporting/general/schema.yaml index 98e9533..489eff6 100644 --- a/models/reporting/general/schema.yaml +++ b/models/reporting/general/schema.yaml @@ -362,6 +362,7 @@ models: It comes from int_dates_mtd logic. tests: - not_null + - latest_date_is_yesterday - name: dimension data_type: string @@ -461,7 +462,8 @@ models: description: The last day of the month or yesterday for historic metrics. tests: - not_null - + - latest_date_is_yesterday + - name: id_deal data_type: character varying description: Id of the deal associated to the host.