From 37af2676cceed51c5ae8456c0ab496497f8c352d Mon Sep 17 00:00:00 2001 From: Jordan Stein Date: Fri, 21 Jul 2023 13:10:46 -0700 Subject: [PATCH 01/16] update metrics spec --- .gitignore | 2 +- dbt_project.yml | 3 +- models/ad_reporting_metrics.yml | 201 ------------------ .../ad_reporting__ad_report_metrics.yaml | 66 ++++++ .../ad_reporting__ad_report.yaml | 56 +++++ .../semantic_models/metricflow_time_spine.sql | 15 ++ 6 files changed, 140 insertions(+), 203 deletions(-) delete mode 100644 models/ad_reporting_metrics.yml create mode 100644 models/metrics/ad_reporting__ad_report_metrics.yaml create mode 100644 models/semantic_models/ad_reporting__ad_report.yaml create mode 100644 models/semantic_models/metricflow_time_spine.sql diff --git a/.gitignore b/.gitignore index d95e577..4e81013 100644 --- a/.gitignore +++ b/.gitignore @@ -3,5 +3,5 @@ target/ dbt_modules/ logs/ .DS_Store - +venv dbt_packages/ \ No newline at end of file diff --git a/dbt_project.yml b/dbt_project.yml index 09f4a87..fd27c05 100644 --- a/dbt_project.yml +++ b/dbt_project.yml @@ -20,4 +20,5 @@ models: +schema: ad_reporting intermediate: +materialized: ephemeral - +schema: int_ad_reporting \ No newline at end of file + +schema: int_ad_reporting +profile: snowflake \ No newline at end of file diff --git a/models/ad_reporting_metrics.yml b/models/ad_reporting_metrics.yml deleted file mode 100644 index c3cbe84..0000000 --- a/models/ad_reporting_metrics.yml +++ /dev/null @@ -1,201 +0,0 @@ -version: 2 - -metrics: - - name: spend - label: Ad spend (Fivetran) - model: ref('ad_reporting__ad_report') - - calculation_method: sum - expression: spend - description: Total spend (in currency of individual platforms) - - timestamp: date_day - time_grains: [day, week, month] - - dimensions: - - platform - - campaign_id - - campaign_name - - ad_group_id - - ad_group_name - - ad_id - - ad_name - - account_id - - account_name - - - name: clicks - label: Ad clicks (Fivetran) - model: ref('ad_reporting__ad_report') - - calculation_method: sum - expression: clicks - description: Total clicks - - timestamp: date_day - time_grains: [day, week, month] - - dimensions: - - platform - - campaign_id - - campaign_name - - ad_group_id - - ad_group_name - - ad_id - - ad_name - - account_id - - account_name - - - name: impressions - label: Ad impressions (Fivetran) - model: ref('ad_reporting__ad_report') - description: Total impressions - - calculation_method: sum - expression: impressions - - timestamp: date_day - time_grains: [day, week, month] - - dimensions: - - platform - - campaign_id - - campaign_name - - ad_group_id - - ad_group_name - - ad_id - - ad_name - - account_id - - account_name - - - name: cost_per_click - label: Average ad cost per click (Fivetran) - description: The ratio of spend to clicks - - calculation_method: derived - expression: "{{ metric('spend') }} / {{ metric('clicks') }}" - - timestamp: date_day - time_grains: [day, week, month] - - dimensions: - - platform - - campaign_id - - campaign_name - - ad_group_id - - ad_group_name - - ad_id - - ad_name - - account_id - - account_name - - - name: bounce_rate - label: Average Ad Bounce Rate (Fivetran) - description: Percentage of impressions that did not convert into clicks. - - calculation_method: derived - expression: "({{ metric('impressions') }} - {{ metric('clicks') }}) / {{ metric('impressions') }}" - - timestamp: date_day - time_grains: [day, week, month] - - dimensions: - - platform - - campaign_id - - campaign_name - - ad_group_id - - ad_group_name - - ad_id - - ad_name - - account_id - - account_name - - - name: clickthrough_rate - label: Ad Clickthrough Rate (Fivetran) - description: Percentage of impressions that did convert into clicks. - - calculation_method: derived - expression: "{{ metric('clicks') }} / {{ metric('impressions') }}" - - timestamp: date_day - time_grains: [day, week, month] - - dimensions: - - platform - - campaign_id - - campaign_name - - ad_group_id - - ad_group_name - - ad_id - - ad_name - - account_id - - account_name - - - name: active_ads - label: Count of Active Ads (Fivetran) - model: ref('ad_reporting__ad_report') - description: Count of ads witth spend > 0. - - calculation_method: count_distinct - expression: ad_id - - timestamp: date_day - time_grains: [day, week, month] - - dimensions: - - platform - - campaign_id - - campaign_name - - ad_group_id - - ad_group_name - - account_id - - account_name - - filters: - - field: spend - operator: '>' - value: '0' - - - name: avg_spend_nonzero - label: Average Spend, Ignore Zeros (Fivetran) - model: ref('ad_reporting__ad_report') - description: Average ad spend, ignores zero-spend days. - - calculation_method: average - expression: spend - - timestamp: date_day - time_grains: [week, month] - - dimensions: - - platform - - campaign_id - - campaign_name - - ad_group_id - - ad_group_name - - account_id - - account_name - - filters: - - field: spend - operator: '>' - value: '0' - - - name: avg_spend - label: Average Spend (Fivetran) - model: ref('ad_reporting__ad_report') - description: Average ad spend, does not ignore zero-spend days. - - calculation_method: average - expression: spend - - timestamp: date_day - time_grains: [week, month] - - dimensions: - - platform - - campaign_id - - campaign_name - - ad_group_id - - ad_group_name - - account_id - - account_name \ No newline at end of file diff --git a/models/metrics/ad_reporting__ad_report_metrics.yaml b/models/metrics/ad_reporting__ad_report_metrics.yaml new file mode 100644 index 0000000..143bedc --- /dev/null +++ b/models/metrics/ad_reporting__ad_report_metrics.yaml @@ -0,0 +1,66 @@ +metrics: + - name: active_ads + description: Count of ads witth spend > 0. + type: simple + type_params: + measure: active_ads + filter: "{{dimension('spend')}} > 0" + label: 'Active Ads (Fivetran)' + - name: avg_spend_nonzero + description: Average ad spend, ignores zero-spend days. + type: simple + type_params: + measure: avg_spend_nonzero + filter: "{{dimension('spend')}} > 0" + label: 'Avg Spend Non-Zero (Fivetran)' + - name: avg_spend + description: Average ad spend, does not ignore zero-spend days. + type: simple + type_params: + measure: avg_spend + label: 'Avg Spend (Fivetran)' + - name: clicks + description: Total clicks + type: simple + type_params: + measure: clicks + label: 'Ad Clicks (Fivetran)' + - name: impressions + description: Total impressions + type: simple + type_params: + measure: impressions + label: 'Ad Impressions (Fivetran)' + - name: spend + description: Total spend (in currency of individual platforms) + type: simple + type_params: + measure: ad_spend + label: 'Ad Spend (Fivetran)' + - name: clickthrough_rate + description: Percentage of impressions that did convert into clicks. + label: Ad Clickthrough Rate (Fivetran) + type: derived + type_params: + expr: clicks/impressions + metrics: + - clicks + - impressions + - name: cost_per_click + description: The ratio of spend to clicks + label: Average ad cost per click (Fivetran) + type: derived + type_params: + expr: spend/clicks + metrics: + - clicks + - spend + - name: bounce_rate + description: Percentage of impressions that did not convert into clicks. + label: Average Ad Bounce Rate (Fivetran) + type: derived + type_params: + expr: impressions - clicks/impressions + metrics: + - impressions + - clicks diff --git a/models/semantic_models/ad_reporting__ad_report.yaml b/models/semantic_models/ad_reporting__ad_report.yaml new file mode 100644 index 0000000..542b550 --- /dev/null +++ b/models/semantic_models/ad_reporting__ad_report.yaml @@ -0,0 +1,56 @@ +semantic_models: + - name: ad_reporting__ad_report + description: Each record represents daily metrics by ad, ad group, campaign and + account. + model: ref('ad_reporting__ad_report') + measures: + - name: ad_spend + agg: sum + expr: spend + agg_time_dimension: date_day + - name: impressions + agg: sum + expr: impressions + agg_time_dimension: date_day + - name: avg_spend + agg: average + expr: spend + agg_time_dimension: date_day + - name: clicks + agg: sum + expr: clicks + agg_time_dimension: date_day + - name: active_ads + agg: count_distinct + expr: ad_id + agg_time_dimension: date_day + - name: avg_spend_nonzero + agg: average + expr: spend + agg_time_dimension: date_day + dimensions: + - name: spend + type: categorical + - name: account_name + type: categorical + - name: ad_name + type: categorical + - name: date_day + type: time + type_params: + time_granularity: day + - name: campaign_name + type: categorical + - name: campaign_id + type: categorical + - name: account_id + type: categorical + - name: ad_id + type: categorical + - name: platform + type: categorical + - name: ad_group_id + type: categorical + - name: ad_group_name + type: categorical + diff --git a/models/semantic_models/metricflow_time_spine.sql b/models/semantic_models/metricflow_time_spine.sql new file mode 100644 index 0000000..cfebfd3 --- /dev/null +++ b/models/semantic_models/metricflow_time_spine.sql @@ -0,0 +1,15 @@ + +--tmp table required by Metricflow for cumulative metrics. We are planning to create this table behind the scenes in core, but for now users will have to create it manually. +{{ config(materialized='table')}} + +with days as ( +{{ dbt_date.get_base_dates(n_dateparts=365*10, datepart="day") }} +), + +final as ( + select cast(date_day as date) as date_day + from days +) + +select * +from final \ No newline at end of file From 58956135df3a4750df5d7fa8d57f8fca3e9bee81 Mon Sep 17 00:00:00 2001 From: Jordan Stein Date: Fri, 21 Jul 2023 13:20:56 -0700 Subject: [PATCH 02/16] update CHANGELOG --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ef4d166..f934862 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # dbt_ad_reporting v1.4.0 +## Update metrics spec and add semantic models +- Updated the metrics spec to reflect the new spec in dbt-core 1.6 +- Added `ad_reporting__ad_report` semantic model which is required to define metrics. +- Added `metricflow_time_spine.sql` which is required for metrics. This will be deprecated in future releases. + ## πŸŽ‰ Feature Enhancement πŸŽ‰ - Added `ad_reporting___passthrough_metrics` variables to easily add common metrics across all platforms into the `ad_reporting` models! This allows metrics other than the standard `clicks`, `impressions`, and `cost` to be included in the final ad reporting models. See below for a full list of new variables and example metrics to passthrough. ([PR #85](https://github.com/fivetran/dbt_ad_reporting/pull/84)) - It is important to call out that this is only possible if the relevant upstream Ad platform variables have the same metric to be unioned in the roll up model. Please see the [README](https://github.com/fivetran/dbt_ad_reporting#optional-step-6-additional-configurations) section for details around how to configure the passthrough metrics. From b8d1cc2e01f9e0ecf61686e57afc53b1e64657b1 Mon Sep 17 00:00:00 2001 From: Jordan Stein Date: Fri, 21 Jul 2023 13:27:09 -0700 Subject: [PATCH 03/16] remove profile --- dbt_project.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/dbt_project.yml b/dbt_project.yml index fd27c05..09f4a87 100644 --- a/dbt_project.yml +++ b/dbt_project.yml @@ -20,5 +20,4 @@ models: +schema: ad_reporting intermediate: +materialized: ephemeral - +schema: int_ad_reporting -profile: snowflake \ No newline at end of file + +schema: int_ad_reporting \ No newline at end of file From 43df96412007bcc6f8c0e192b283f9b81d32ff92 Mon Sep 17 00:00:00 2001 From: Jordan Stein Date: Wed, 26 Jul 2023 18:17:49 -0700 Subject: [PATCH 04/16] delete time spine model --- models/semantic_models/metricflow_time_spine.sql | 15 --------------- 1 file changed, 15 deletions(-) delete mode 100644 models/semantic_models/metricflow_time_spine.sql diff --git a/models/semantic_models/metricflow_time_spine.sql b/models/semantic_models/metricflow_time_spine.sql deleted file mode 100644 index cfebfd3..0000000 --- a/models/semantic_models/metricflow_time_spine.sql +++ /dev/null @@ -1,15 +0,0 @@ - ---tmp table required by Metricflow for cumulative metrics. We are planning to create this table behind the scenes in core, but for now users will have to create it manually. -{{ config(materialized='table')}} - -with days as ( -{{ dbt_date.get_base_dates(n_dateparts=365*10, datepart="day") }} -), - -final as ( - select cast(date_day as date) as date_day - from days -) - -select * -from final \ No newline at end of file From 2e4d6476864a681075019e1bae773cac7ec8b040 Mon Sep 17 00:00:00 2001 From: Jordan Stein Date: Thu, 3 Aug 2023 09:10:00 -0600 Subject: [PATCH 05/16] update spec for 1.6 --- models/metrics/ad_reporting__ad_report_metrics.yaml | 6 ++++-- models/semantic_models/ad_reporting__ad_report.yaml | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/models/metrics/ad_reporting__ad_report_metrics.yaml b/models/metrics/ad_reporting__ad_report_metrics.yaml index 143bedc..e4074ef 100644 --- a/models/metrics/ad_reporting__ad_report_metrics.yaml +++ b/models/metrics/ad_reporting__ad_report_metrics.yaml @@ -4,14 +4,16 @@ metrics: type: simple type_params: measure: active_ads - filter: "{{dimension('spend')}} > 0" + filter: | + {{Dimension('ad__spend')}} > 0 label: 'Active Ads (Fivetran)' - name: avg_spend_nonzero description: Average ad spend, ignores zero-spend days. type: simple type_params: measure: avg_spend_nonzero - filter: "{{dimension('spend')}} > 0" + filter: | + {{Dimension('ad__spend')}} > 0 label: 'Avg Spend Non-Zero (Fivetran)' - name: avg_spend description: Average ad spend, does not ignore zero-spend days. diff --git a/models/semantic_models/ad_reporting__ad_report.yaml b/models/semantic_models/ad_reporting__ad_report.yaml index 542b550..7457e01 100644 --- a/models/semantic_models/ad_reporting__ad_report.yaml +++ b/models/semantic_models/ad_reporting__ad_report.yaml @@ -3,6 +3,7 @@ semantic_models: description: Each record represents daily metrics by ad, ad group, campaign and account. model: ref('ad_reporting__ad_report') + primary_entity: ad measures: - name: ad_spend agg: sum From 5cd53724cb5866312403677bd0baeb4ab9c94724 Mon Sep 17 00:00:00 2001 From: Jordan Stein Date: Mon, 7 Aug 2023 15:11:59 -0700 Subject: [PATCH 06/16] update readme + version requirement --- README.md | 30 +++++-------------- dbt_project.yml | 2 +- .../ad_reporting__ad_report_metrics.yaml | 6 ++-- 3 files changed, 11 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index d4285e8..c75c164 100644 --- a/README.md +++ b/README.md @@ -461,10 +461,10 @@ Fivetran offers the ability for you to orchestrate your dbt project through [Fiv
-## (Optional) Step 8: Use predefined Metrics +## (Optional) Step 8: Use predefined Metrics and the dbt Semantic Layer
Expand for details -On top of the `ad_reporting__ad_report` final model, the Ad Reporting dbt package defines common [Metrics](https://docs.getdbt.com/docs/building-a-dbt-project/metrics), including: +On top of the `ad_reporting__ad_report` final model, the Ad Reporting dbt package defines common [Metrics](https://docs.getdbt.com/docs/build/build-metrics-intro) using [MetricFlow](https://docs.getdbt.com/docs/build/about-metricflow) that can be queried with the [dbt Semantic Layer](https://docs.getdbt.com/docs/use-dbt-semantic-layer/dbt-sl). These metrics include: - Spend - Impressions - Clicks @@ -475,27 +475,11 @@ On top of the `ad_reporting__ad_report` final model, the Ad Reporting dbt packag - Average spend - Average non-zero spend -You can find the supported dimensions and full definitions of these metrics [here](https://github.com/fivetran/dbt_ad_reporting/blob/main/models/ad_reporting_metrics.yml). - -To use dbt Metrics, please refer to the [dbt metrics package](https://github.com/dbt-labs/dbt_metrics) and install the relevant version to your project's `packages.yml` file. - -> **Note**: The Metrics package has stricter dbt version requirements, therefore, please take note of the correct dbt version for your desired version of dbt Metrics. - -To utilize the Ad Reporting's pre-defined metrics in your code, refer to the [dbt metrics package](https://github.com/dbt-labs/dbt_metrics) usage instructions and the example below: -```sql -select * -from {{ metrics.calculate( - metric('clicks'), - grain='month', - dimensions=['platform', - 'campaign_id', - 'campaign_name' - ], - secondary_calculations=[ - metrics.period_over_period(comparison_strategy='difference', interval=1, alias='diff_last_mth'), - metrics.period_over_period(comparison_strategy='ratio', interval=1, alias='ratio_last_mth') - ] -) }} +You can find the supported dimensions and full definitions of these metrics [here](https://github.com/fivetran/dbt_ad_reporting/blob/main/models/ad_reporting_metrics.yml), and the semantic model definitions [here](https://github.com/fivetran/dbt_ad_reporting/blob/main/models/metrics/models/semantic_models/ad_reporting__ad_report.yaml). + +Refer to the Semantic Layer [quickstart guide](https://docs.getdbt.com/docs/use-dbt-semantic-layer/quickstart-sl) for instructions on how to get setup with the dbt Semantic Layer and start querying these metrics. + +> **Note**: The Metricflow is only supported in dbt>=v1.6, therefore, please take note of the correct dbt version. ```
diff --git a/dbt_project.yml b/dbt_project.yml index 09f4a87..5c38d5e 100644 --- a/dbt_project.yml +++ b/dbt_project.yml @@ -3,7 +3,7 @@ version: '1.4.0' config-version: 2 -require-dbt-version: [">=1.3.0", "<2.0.0"] +require-dbt-version: [">=1.6.0", "<2.0.0"] vars: ad_reporting: diff --git a/models/metrics/ad_reporting__ad_report_metrics.yaml b/models/metrics/ad_reporting__ad_report_metrics.yaml index e4074ef..90afe20 100644 --- a/models/metrics/ad_reporting__ad_report_metrics.yaml +++ b/models/metrics/ad_reporting__ad_report_metrics.yaml @@ -41,7 +41,7 @@ metrics: label: 'Ad Spend (Fivetran)' - name: clickthrough_rate description: Percentage of impressions that did convert into clicks. - label: Ad Clickthrough Rate (Fivetran) + label: 'Ad Clickthrough Rate (Fivetran)' type: derived type_params: expr: clicks/impressions @@ -50,7 +50,7 @@ metrics: - impressions - name: cost_per_click description: The ratio of spend to clicks - label: Average ad cost per click (Fivetran) + label: 'Average Ad Cost Per Click (Fivetran)' type: derived type_params: expr: spend/clicks @@ -59,7 +59,7 @@ metrics: - spend - name: bounce_rate description: Percentage of impressions that did not convert into clicks. - label: Average Ad Bounce Rate (Fivetran) + label: 'Average Ad Bounce Rate (Fivetran)' type: derived type_params: expr: impressions - clicks/impressions From 704146a4fdc8924250a1597d5130364372c2ba22 Mon Sep 17 00:00:00 2001 From: Jordan Stein Date: Tue, 8 Aug 2023 14:46:10 -0700 Subject: [PATCH 07/16] add back metricflow time spine + update readme --- CHANGELOG.md | 2 +- README.md | 5 ++++- dbt_project.yml | 3 +++ models/metricflow_time_spine.sql | 18 ++++++++++++++++++ ...aml => ad_reporting__ad_report_metrics.yml} | 0 ...report.yaml => ad_reporting__ad_report.yml} | 0 6 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 models/metricflow_time_spine.sql rename models/metrics/{ad_reporting__ad_report_metrics.yaml => ad_reporting__ad_report_metrics.yml} (100%) rename models/semantic_models/{ad_reporting__ad_report.yaml => ad_reporting__ad_report.yml} (100%) diff --git a/CHANGELOG.md b/CHANGELOG.md index f934862..9630916 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ ## Update metrics spec and add semantic models - Updated the metrics spec to reflect the new spec in dbt-core 1.6 - Added `ad_reporting__ad_report` semantic model which is required to define metrics. -- Added `metricflow_time_spine.sql` which is required for metrics. This will be deprecated in future releases. +- Added `metricflow_time_spine.sql` which is required by Metricflow. This will be deprecated in future releases. If you have already created a `metricflow_time_spine.sql` model in your project, you will need to disable it for this package by setting the variable `metricflow_time_spine: false` in your dbt_project.yml ## πŸŽ‰ Feature Enhancement πŸŽ‰ - Added `ad_reporting___passthrough_metrics` variables to easily add common metrics across all platforms into the `ad_reporting` models! This allows metrics other than the standard `clicks`, `impressions`, and `cost` to be included in the final ad reporting models. See below for a full list of new variables and example metrics to passthrough. ([PR #85](https://github.com/fivetran/dbt_ad_reporting/pull/84)) diff --git a/README.md b/README.md index c75c164..edfacf1 100644 --- a/README.md +++ b/README.md @@ -479,7 +479,10 @@ You can find the supported dimensions and full definitions of these metrics [her Refer to the Semantic Layer [quickstart guide](https://docs.getdbt.com/docs/use-dbt-semantic-layer/quickstart-sl) for instructions on how to get setup with the dbt Semantic Layer and start querying these metrics. -> **Note**: The Metricflow is only supported in dbt>=v1.6, therefore, please take note of the correct dbt version. +**Metricflow Time Spine Configuration** +This package includes a model called `metricflow_time_spine.sql` that MetricFlow requires to build cumulative metrics. Documentation on the metricflow time spine model can be [found here.](https://docs.getdbt.com/docs/build/metricflow-time-spine) If you have already configured a metricflow time spine model in your project, you will need to disable the one in this package by adding the `metricflow_time_spine: False` env variable to your dbt_project.yml. + +> **Note**: Metricflow is only supported in dbt>=v1.6, therefore, please take note of the correct dbt version. ``` diff --git a/dbt_project.yml b/dbt_project.yml index 5c38d5e..33d12ba 100644 --- a/dbt_project.yml +++ b/dbt_project.yml @@ -2,6 +2,7 @@ name: 'ad_reporting' version: '1.4.0' config-version: 2 +profile: snowflake require-dbt-version: [">=1.6.0", "<2.0.0"] @@ -13,6 +14,8 @@ vars: ad_reporting__ad_passthrough_metrics: [] ad_reporting__keyword_passthrough_metrics: [] ad_reporting__search_passthrough_metrics: [] + metricflow_time_spine: false + "dbt_date:time_zone": "America/Los_Angeles" models: ad_reporting: diff --git a/models/metricflow_time_spine.sql b/models/metricflow_time_spine.sql new file mode 100644 index 0000000..ee4a188 --- /dev/null +++ b/models/metricflow_time_spine.sql @@ -0,0 +1,18 @@ +{{ config(enabled=var('metricflow_time_spine', True)) }} +with + +days as ( + {{ dbt_date.get_base_dates(n_dateparts=365*10, datepart="day") }} + +), + +cast_to_date as ( + + select + cast(date_day as date) as date_day + + from days + +) + +select * from cast_to_date diff --git a/models/metrics/ad_reporting__ad_report_metrics.yaml b/models/metrics/ad_reporting__ad_report_metrics.yml similarity index 100% rename from models/metrics/ad_reporting__ad_report_metrics.yaml rename to models/metrics/ad_reporting__ad_report_metrics.yml diff --git a/models/semantic_models/ad_reporting__ad_report.yaml b/models/semantic_models/ad_reporting__ad_report.yml similarity index 100% rename from models/semantic_models/ad_reporting__ad_report.yaml rename to models/semantic_models/ad_reporting__ad_report.yml From 3c7389eb3a482114aa2b1752b2594faa2437fdbd Mon Sep 17 00:00:00 2001 From: Jordan Stein Date: Tue, 8 Aug 2023 14:47:02 -0700 Subject: [PATCH 08/16] remove metricflow_time_spine: false env var --- dbt_project.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/dbt_project.yml b/dbt_project.yml index 33d12ba..3c07c10 100644 --- a/dbt_project.yml +++ b/dbt_project.yml @@ -14,7 +14,6 @@ vars: ad_reporting__ad_passthrough_metrics: [] ad_reporting__keyword_passthrough_metrics: [] ad_reporting__search_passthrough_metrics: [] - metricflow_time_spine: false "dbt_date:time_zone": "America/Los_Angeles" models: From f60b920aa8f8d67a5d44f21af7e3c9f3c55a2b6d Mon Sep 17 00:00:00 2001 From: Jordan Stein Date: Tue, 8 Aug 2023 14:55:46 -0700 Subject: [PATCH 09/16] add semantic manifest docs + move time spine model --- README.md | 5 +++++ models/{ => semantic_models}/metricflow_time_spine.sql | 0 2 files changed, 5 insertions(+) rename models/{ => semantic_models}/metricflow_time_spine.sql (100%) diff --git a/README.md b/README.md index edfacf1..901e018 100644 --- a/README.md +++ b/README.md @@ -482,7 +482,12 @@ Refer to the Semantic Layer [quickstart guide](https://docs.getdbt.com/docs/use- **Metricflow Time Spine Configuration** This package includes a model called `metricflow_time_spine.sql` that MetricFlow requires to build cumulative metrics. Documentation on the metricflow time spine model can be [found here.](https://docs.getdbt.com/docs/build/metricflow-time-spine) If you have already configured a metricflow time spine model in your project, you will need to disable the one in this package by adding the `metricflow_time_spine: False` env variable to your dbt_project.yml. +**Semantic Manifest** +You may notice a new run artifact called `semantic_manifest.json`. This file serves as the integation point between dbt-core and metricflow, and contains all the information MetricFlow needs to build a semantic graph, and generate SQL from query requests. You can learn more about the semantic manifest file [in the docs](https://docs.getdbt.com/docs/dbt-cloud-apis/sl-manifest). + > **Note**: Metricflow is only supported in dbt>=v1.6, therefore, please take note of the correct dbt version. + + ``` diff --git a/models/metricflow_time_spine.sql b/models/semantic_models/metricflow_time_spine.sql similarity index 100% rename from models/metricflow_time_spine.sql rename to models/semantic_models/metricflow_time_spine.sql From 22398c82bd1756a740736eb2d8809fa18244a5f9 Mon Sep 17 00:00:00 2001 From: Joe Markiewicz <74217849+fivetran-joemarkiewicz@users.noreply.github.com> Date: Wed, 9 Aug 2023 16:29:36 -0500 Subject: [PATCH 10/16] review updates --- CHANGELOG.md | 33 ++++++++++++++++--- README.md | 24 +++++++++++--- dbt_project.yml | 2 +- .../semantic_models/metricflow_time_spine.sql | 2 +- 4 files changed, 49 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9630916..af7e9a2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,33 @@ -# dbt_ad_reporting v1.4.0 +# dbt_ad_reporting v1.6.0 +[PR #100](https://github.com/fivetran/dbt_ad_reporting/pull/100) includes the following updates. + +## 🚨 New dbt-core version requirement 🚨 +- Updated the metrics spec to reflect the new spec in dbt-core 1.6.0. As a result, the new required dbt version is `[">=1.6.0", "<2.0.0"]`. Be sure to upgrade your dbt-core version when upgrading this package to avoid dbt version compatibility errors. + +## Feature Updates +- Added `ad_reporting__ad_report.yml` semantic model which is required to define metrics. +- Included `metricflow_time_spine.sql` which is required by Metricflow. This will be deprecated in future releases. If you have already created a `metricflow_time_spine.sql` model in your project, you will need to disable it for this package by setting the variable `ad_reporting__metricflow_time_spine` to `false in your project. + +```yml +## root dbt_project.yml +vars: + ad_reporting__metricflow_time_spine: false ## true by default +``` -## Update metrics spec and add semantic models -- Updated the metrics spec to reflect the new spec in dbt-core 1.6 -- Added `ad_reporting__ad_report` semantic model which is required to define metrics. -- Added `metricflow_time_spine.sql` which is required by Metricflow. This will be deprecated in future releases. If you have already created a `metricflow_time_spine.sql` model in your project, you will need to disable it for this package by setting the variable `metricflow_time_spine: false` in your dbt_project.yml +## Under the Hood +- Added a new variable `dbt_date:time_zone` which is used by the `dbt_date.get_base_dates` macro within the `metricflow_time_spine` model. This variable is nested under the `ad_reporting` hierarchy in the variables config and should not affect any global declarations if you leverage the `dbt_date` package in your own environment. + - The default value of this variable is `America/Los_Angeles`, but you may be able override this in your own root project. +```yml +## root dbt_project.yml +vars: + "dbt_date:time_zone": "America/Chicago" # Default is "America/Los_Angeles" +``` + +## Contributors +- [@Jstein77](https://github.com/Jstein77) ([PR #100](https://github.com/fivetran/dbt_ad_reporting/pull/100)) + +# dbt_ad_reporting v1.4.0 ## πŸŽ‰ Feature Enhancement πŸŽ‰ - Added `ad_reporting___passthrough_metrics` variables to easily add common metrics across all platforms into the `ad_reporting` models! This allows metrics other than the standard `clicks`, `impressions`, and `cost` to be included in the final ad reporting models. See below for a full list of new variables and example metrics to passthrough. ([PR #85](https://github.com/fivetran/dbt_ad_reporting/pull/84)) - It is important to call out that this is only possible if the relevant upstream Ad platform variables have the same metric to be unioned in the roll up model. Please see the [README](https://github.com/fivetran/dbt_ad_reporting#optional-step-6-additional-configurations) section for details around how to configure the passthrough metrics. diff --git a/README.md b/README.md index 901e018..7850cd0 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ href="https://github.com/fivetran/dbt_github/blob/main/LICENSE"> - + @@ -77,7 +77,7 @@ Include the following github package version in your `packages.yml` ```yaml packages: - package: fivetran/ad_reporting - version: [">=1.4.0", "<1.5.0"] # we recommend using ranges to capture non-breaking changes automatically + version: [">=1.6.0", "<1.7.0"] # we recommend using ranges to capture non-breaking changes automatically ``` Do NOT include the individual ad platform packages in this file. The ad reporting package itself has dependencies on these packages and will install them as well. @@ -480,13 +480,27 @@ You can find the supported dimensions and full definitions of these metrics [her Refer to the Semantic Layer [quickstart guide](https://docs.getdbt.com/docs/use-dbt-semantic-layer/quickstart-sl) for instructions on how to get setup with the dbt Semantic Layer and start querying these metrics. **Metricflow Time Spine Configuration** -This package includes a model called `metricflow_time_spine.sql` that MetricFlow requires to build cumulative metrics. Documentation on the metricflow time spine model can be [found here.](https://docs.getdbt.com/docs/build/metricflow-time-spine) If you have already configured a metricflow time spine model in your project, you will need to disable the one in this package by adding the `metricflow_time_spine: False` env variable to your dbt_project.yml. +This package includes a model called `metricflow_time_spine.sql` that MetricFlow requires to build cumulative metrics. Documentation on the metricflow time spine model can be [found here.](https://docs.getdbt.com/docs/build/metricflow-time-spine) If you have already configured a metricflow time spine model in your project, you will need to disable the one in this package by defining the `ad_reporting__metricflow_time_spine` variable as `false` in your project. + +```yml +## root dbt_project.yml +vars: + ad_reporting__metricflow_time_spine: false ## true by default +``` +Additionally, the `dbt_date.get_base_dates` macro is used in the generation of the `metricsflow_time_spine.sql` model. This macro requires the `dbt_date:time_zone` variable to be defined in the project to generate a time spine based on the defined time zone. The default value in this package is `America/Los_Angeles`. However, you may override this variable in your own project if you wish. + +>**Note**: This variable is defined under the `ad_reporting` hierarchy within this package and should not adjust any local global variable values in your project if you already have this variable defined. + +```yml +## root dbt_project.yml +vars: + "dbt_date:time_zone": "America/Chicago" # Default is "America/Los_Angeles" +``` **Semantic Manifest** You may notice a new run artifact called `semantic_manifest.json`. This file serves as the integation point between dbt-core and metricflow, and contains all the information MetricFlow needs to build a semantic graph, and generate SQL from query requests. You can learn more about the semantic manifest file [in the docs](https://docs.getdbt.com/docs/dbt-cloud-apis/sl-manifest). -> **Note**: Metricflow is only supported in dbt>=v1.6, therefore, please take note of the correct dbt version. - +> **Note**: Metricflow is only supported in dbt>=v1.6.0, therefore, please take note of the correct dbt version. ``` diff --git a/dbt_project.yml b/dbt_project.yml index 3c07c10..2a2ed7e 100644 --- a/dbt_project.yml +++ b/dbt_project.yml @@ -14,7 +14,7 @@ vars: ad_reporting__ad_passthrough_metrics: [] ad_reporting__keyword_passthrough_metrics: [] ad_reporting__search_passthrough_metrics: [] - "dbt_date:time_zone": "America/Los_Angeles" + "dbt_date:time_zone": "America/Los_Angeles" models: ad_reporting: diff --git a/models/semantic_models/metricflow_time_spine.sql b/models/semantic_models/metricflow_time_spine.sql index ee4a188..4d18b85 100644 --- a/models/semantic_models/metricflow_time_spine.sql +++ b/models/semantic_models/metricflow_time_spine.sql @@ -1,4 +1,4 @@ -{{ config(enabled=var('metricflow_time_spine', True)) }} +{{ config(enabled=var('ad_reporting__metricflow_time_spine', True)) }} with days as ( From 4c264e79c42435e65f7fc0da59c344777e98873e Mon Sep 17 00:00:00 2001 From: Joe Markiewicz <74217849+fivetran-joemarkiewicz@users.noreply.github.com> Date: Wed, 9 Aug 2023 16:30:31 -0500 Subject: [PATCH 11/16] removed profile --- dbt_project.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/dbt_project.yml b/dbt_project.yml index 2a2ed7e..e3983d6 100644 --- a/dbt_project.yml +++ b/dbt_project.yml @@ -2,7 +2,6 @@ name: 'ad_reporting' version: '1.4.0' config-version: 2 -profile: snowflake require-dbt-version: [">=1.6.0", "<2.0.0"] From 779e47c3775a68f959859846428460b35b7fec5e Mon Sep 17 00:00:00 2001 From: Joe Markiewicz <74217849+fivetran-joemarkiewicz@users.noreply.github.com> Date: Wed, 9 Aug 2023 16:31:59 -0500 Subject: [PATCH 12/16] enabled --- CHANGELOG.md | 4 ++-- README.md | 4 ++-- models/semantic_models/metricflow_time_spine.sql | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index af7e9a2..c4b5db0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,12 +6,12 @@ ## Feature Updates - Added `ad_reporting__ad_report.yml` semantic model which is required to define metrics. -- Included `metricflow_time_spine.sql` which is required by Metricflow. This will be deprecated in future releases. If you have already created a `metricflow_time_spine.sql` model in your project, you will need to disable it for this package by setting the variable `ad_reporting__metricflow_time_spine` to `false in your project. +- Included `metricflow_time_spine.sql` which is required by Metricflow. This will be deprecated in future releases. If you have already created a `metricflow_time_spine.sql` model in your project, you will need to disable it for this package by setting the variable `ad_reporting__metricflow_time_spine_enabled` to `false in your project. ```yml ## root dbt_project.yml vars: - ad_reporting__metricflow_time_spine: false ## true by default + ad_reporting__metricflow_time_spine_enabled: false ## true by default ``` ## Under the Hood diff --git a/README.md b/README.md index 7850cd0..d450de2 100644 --- a/README.md +++ b/README.md @@ -480,12 +480,12 @@ You can find the supported dimensions and full definitions of these metrics [her Refer to the Semantic Layer [quickstart guide](https://docs.getdbt.com/docs/use-dbt-semantic-layer/quickstart-sl) for instructions on how to get setup with the dbt Semantic Layer and start querying these metrics. **Metricflow Time Spine Configuration** -This package includes a model called `metricflow_time_spine.sql` that MetricFlow requires to build cumulative metrics. Documentation on the metricflow time spine model can be [found here.](https://docs.getdbt.com/docs/build/metricflow-time-spine) If you have already configured a metricflow time spine model in your project, you will need to disable the one in this package by defining the `ad_reporting__metricflow_time_spine` variable as `false` in your project. +This package includes a model called `metricflow_time_spine.sql` that MetricFlow requires to build cumulative metrics. Documentation on the metricflow time spine model can be [found here.](https://docs.getdbt.com/docs/build/metricflow-time-spine) If you have already configured a metricflow time spine model in your project, you will need to disable the one in this package by defining the `ad_reporting__metricflow_time_spine_enabled` variable as `false` in your project. ```yml ## root dbt_project.yml vars: - ad_reporting__metricflow_time_spine: false ## true by default + ad_reporting__metricflow_time_spine_enabled: false ## true by default ``` Additionally, the `dbt_date.get_base_dates` macro is used in the generation of the `metricsflow_time_spine.sql` model. This macro requires the `dbt_date:time_zone` variable to be defined in the project to generate a time spine based on the defined time zone. The default value in this package is `America/Los_Angeles`. However, you may override this variable in your own project if you wish. diff --git a/models/semantic_models/metricflow_time_spine.sql b/models/semantic_models/metricflow_time_spine.sql index 4d18b85..32c0ab1 100644 --- a/models/semantic_models/metricflow_time_spine.sql +++ b/models/semantic_models/metricflow_time_spine.sql @@ -1,4 +1,4 @@ -{{ config(enabled=var('ad_reporting__metricflow_time_spine', True)) }} +{{ config(enabled=var('ad_reporting__metricflow_time_spine_enabled', True)) }} with days as ( From b5319207ba94fa45c9c6c86917122705edc84f72 Mon Sep 17 00:00:00 2001 From: Joe Markiewicz <74217849+fivetran-joemarkiewicz@users.noreply.github.com> Date: Wed, 9 Aug 2023 17:40:31 -0500 Subject: [PATCH 13/16] docs notice in changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c4b5db0..d82b187 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,9 @@ vars: "dbt_date:time_zone": "America/Chicago" # Default is "America/Los_Angeles" ``` +## Documentation +- Please be aware that due to a bug in dbt-core v1.6.0 the docs were not regenerated as part of this release. You can expect a new release in the future with the regenerated docs that contain these updates. + ## Contributors - [@Jstein77](https://github.com/Jstein77) ([PR #100](https://github.com/fivetran/dbt_ad_reporting/pull/100)) From 8c826a7d9e8c8b6864dfe5a76e19947d06c68fb1 Mon Sep 17 00:00:00 2001 From: Joe Markiewicz <74217849+fivetran-joemarkiewicz@users.noreply.github.com> Date: Wed, 9 Aug 2023 17:50:54 -0500 Subject: [PATCH 14/16] readme collapse fix --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index 47226e2..ec42232 100644 --- a/README.md +++ b/README.md @@ -502,8 +502,6 @@ You may notice a new run artifact called `semantic_manifest.json`. This file ser > **Note**: Metricflow is only supported in dbt>=v1.6.0, therefore, please take note of the correct dbt version. -``` -
From dbd2517b763cb73e4d63853937ea2a565dc85a76 Mon Sep 17 00:00:00 2001 From: Joe Markiewicz <74217849+fivetran-joemarkiewicz@users.noreply.github.com> Date: Wed, 9 Aug 2023 17:53:03 -0500 Subject: [PATCH 15/16] version upgrade --- dbt_project.yml | 2 +- integration_tests/dbt_project.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dbt_project.yml b/dbt_project.yml index f3172c7..7517b3c 100644 --- a/dbt_project.yml +++ b/dbt_project.yml @@ -1,5 +1,5 @@ name: 'ad_reporting' -version: '1.5.0' +version: '1.6.0' config-version: 2 diff --git a/integration_tests/dbt_project.yml b/integration_tests/dbt_project.yml index b1d6c8b..5dde7ce 100644 --- a/integration_tests/dbt_project.yml +++ b/integration_tests/dbt_project.yml @@ -1,5 +1,5 @@ name: 'ad_reporting_integration_tests' -version: '1.5.0' +version: '1.6.0' profile: 'integration_tests' config-version: 2 From ce2d939725a87ce85fad296896778aaf230536a9 Mon Sep 17 00:00:00 2001 From: Joe Markiewicz <74217849+fivetran-joemarkiewicz@users.noreply.github.com> Date: Thu, 10 Aug 2023 10:26:38 -0500 Subject: [PATCH 16/16] review updates --- CHANGELOG.md | 4 ++-- README.md | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 57bb95e..ad68bba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ ## Feature Updates - Added `ad_reporting__ad_report.yml` semantic model which is required to define metrics. -- Included `metricflow_time_spine.sql` which is required by Metricflow. This will be deprecated in future releases. If you have already created a `metricflow_time_spine.sql` model in your project, you will need to disable it for this package by setting the variable `ad_reporting__metricflow_time_spine_enabled` to `false in your project. +- Included `metricflow_time_spine.sql` which is required by Metricflow. This will be deprecated in future releases. If you have already created a `metricflow_time_spine.sql` model in your project, you will need to disable it for this package by setting the variable `ad_reporting__metricflow_time_spine_enabled` to `false` in your project. ```yml ## root dbt_project.yml @@ -17,7 +17,7 @@ vars: ## Under the Hood - Added a new variable `dbt_date:time_zone` which is used by the `dbt_date.get_base_dates` macro within the `metricflow_time_spine` model. This variable is nested under the `ad_reporting` hierarchy in the variables config and should not affect any global declarations if you leverage the `dbt_date` package in your own environment. - - The default value of this variable is `America/Los_Angeles`, but you may be able override this in your own root project. + - The default value of this variable is `America/Los_Angeles`, but you may be able override this in your own root project. For more information on why this variable is needed and the different value options, refer to the [dbt-date package documentation](https://github.com/calogica/dbt-date#variables). ```yml ## root dbt_project.yml diff --git a/README.md b/README.md index ec42232..1dca17f 100644 --- a/README.md +++ b/README.md @@ -489,7 +489,7 @@ vars: ``` Additionally, the `dbt_date.get_base_dates` macro is used in the generation of the `metricsflow_time_spine.sql` model. This macro requires the `dbt_date:time_zone` variable to be defined in the project to generate a time spine based on the defined time zone. The default value in this package is `America/Los_Angeles`. However, you may override this variable in your own project if you wish. ->**Note**: This variable is defined under the `ad_reporting` hierarchy within this package and should not adjust any local global variable values in your project if you already have this variable defined. +>**Note**: This variable is defined under the `ad_reporting` hierarchy within this package and should not adjust any local global variable values in your project if you already have this variable defined. For more information on why this variable is needed and the different value options, refer to the [dbt-date package documentation](https://github.com/calogica/dbt-date#variables). ```yml ## root dbt_project.yml