From 32caac73dc8a04ed0109bcdd4420d38d03dba860 Mon Sep 17 00:00:00 2001 From: Robbert Hofman Date: Wed, 8 Feb 2023 18:48:20 +0100 Subject: [PATCH 1/4] convert_timezone for dbt_date --- macros/convert_timezone.sql | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 macros/convert_timezone.sql diff --git a/macros/convert_timezone.sql b/macros/convert_timezone.sql new file mode 100644 index 0000000..45ea1b5 --- /dev/null +++ b/macros/convert_timezone.sql @@ -0,0 +1,3 @@ +{%- macro trino__convert_timezone(column, target_tz, source_tz=None) -%} +{{ column }} at time zone '{{ target_tz }}' +{%- endmacro -%} From 1d47c26f0a5a42c675a71268fa1f229f8997215e Mon Sep 17 00:00:00 2001 From: Robbert Hofman Date: Wed, 8 Feb 2023 18:50:16 +0100 Subject: [PATCH 2/4] move sql file to folder of package it shims --- macros/{ => dbt_date}/convert_timezone.sql | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename macros/{ => dbt_date}/convert_timezone.sql (100%) diff --git a/macros/convert_timezone.sql b/macros/dbt_date/convert_timezone.sql similarity index 100% rename from macros/convert_timezone.sql rename to macros/dbt_date/convert_timezone.sql From 8642f963b40e66ecf0f50b320964c05ffb26c3a2 Mon Sep 17 00:00:00 2001 From: Robbert Hofman Date: Wed, 8 Feb 2023 18:50:59 +0100 Subject: [PATCH 3/4] gen_calendar_join for dbt_metrics difference between dateadd and date_add --- macros/dbt_metrics/gen_calendar_join.sql | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 macros/dbt_metrics/gen_calendar_join.sql diff --git a/macros/dbt_metrics/gen_calendar_join.sql b/macros/dbt_metrics/gen_calendar_join.sql new file mode 100644 index 0000000..febdbe9 --- /dev/null +++ b/macros/dbt_metrics/gen_calendar_join.sql @@ -0,0 +1,9 @@ +{% macro trino__gen_calendar_join(group_values) %} + left join calendar + {%- if group_values.window is not none %} + on cast(base_model.{{group_values.timestamp}} as date) > date_add('{{group_values.window.period}}', -{{group_values.window.count}}, calendar.date_day) + and cast(base_model.{{group_values.timestamp}} as date) <= calendar.date_day + {%- else %} + on cast(base_model.{{group_values.timestamp}} as date) = calendar.date_day + {% endif -%} +{% endmacro %} From 70426ca1b619ab45eb29184f02934ae22731d594 Mon Sep 17 00:00:00 2001 From: Robbert Hofman Date: Wed, 8 Feb 2023 19:05:01 +0100 Subject: [PATCH 4/4] update readme to include dbt_date and metrics packages --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 9c41132..20ea436 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,8 @@ that: This package provides "shims" for: - [dbt_utils](https://github.com/dbt-labs/dbt-utils) (partial) +- [dbt_date](https://github.com/calogica/dbt-date) (partial) +- [metrics](https://github.com/dbt-labs/dbt_metrics/) ## Usage @@ -31,6 +33,10 @@ To make use of these trino adaptations in your dbt project, you must do two thin dispatch: - macro_namespace: dbt_utils search_order: ['trino_utils', 'dbt_utils'] + - macro_namespace: dbt_date + search_order: ['trino_utils', 'dbt_date'] + - macro_namespace: metrics + search_order: ['trino_utils', 'metrics'] ``` Check [dbt Hub](https://hub.getdbt.com) for the latest installation instructions, or [read the docs](https://docs.getdbt.com/docs/package-management)