From 2ac8500c2c2435590a25b8d68a3c9a86937d8a4e Mon Sep 17 00:00:00 2001
From: Jamie Rodriguez <65564846+fivetran-jamie@users.noreply.github.com>
Date: Thu, 8 Sep 2022 15:07:49 -0700
Subject: [PATCH 01/11] defining metrics to use in hex
---
models/ad_reporting_metrics.yml | 216 ++++++++++++++++++
..._reporting.yml => ad_reporting_models.yml} | 0
packages.yml | 5 +-
3 files changed, 220 insertions(+), 1 deletion(-)
create mode 100644 models/ad_reporting_metrics.yml
rename models/{ad_reporting.yml => ad_reporting_models.yml} (100%)
diff --git a/models/ad_reporting_metrics.yml b/models/ad_reporting_metrics.yml
new file mode 100644
index 0000000..be79dbe
--- /dev/null
+++ b/models/ad_reporting_metrics.yml
@@ -0,0 +1,216 @@
+version: 2
+
+metrics:
+ - name: spend
+ label: Ad spend (Fivetran)
+ model: ref('ad_reporting__ad_report')
+
+ type: sum
+ sql: spend
+
+ timestamp: date_day
+ time_grains: [day, week, month]
+
+ dimensions:
+ - platform
+ - campaign_id # do i include name?
+ - 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')
+
+ type: sum
+ sql: 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')
+
+ type: sum
+ sql: 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)
+ model: ref('ad_reporting__ad_report')
+
+ type: expression
+ sql: "{{ 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
+
+ filters:
+ - field: clicks
+ operator: '>'
+ value: '0'
+
+ - name: bounce_rate
+ label: Average Ad Bounce Rate (Fivetran)
+ model: ref('ad_reporting__ad_report')
+ description: Percentage of impressions that did not convert into clicks.
+
+ type: expression
+ sql: "({{ 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
+
+ filters:
+ - field: impressions
+ operator: '>'
+ value: '0'
+
+ - name: clickthrough_rate
+ label: Ad Clickthrough Rate (Fivetran)
+ model: ref('ad_reporting__ad_report')
+ description: Percentage of impressions that did convert into clicks.
+
+ type: expression
+ sql: "{{ 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
+
+ # maybe add a filter around the spend?
+ filters:
+ - field: impressions
+ operator: '>'
+ value: '0'
+
+ - name: active_ads
+ label: Count of Active Ads (Fivetran)
+ model: ref('ad_reporting__ad_report')
+ description: Count of ads witth spend > 0.
+
+ type: count_distinct
+ sql: 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.
+
+ type: average
+ sql: 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.
+
+ type: average
+ sql: 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/ad_reporting.yml b/models/ad_reporting_models.yml
similarity index 100%
rename from models/ad_reporting.yml
rename to models/ad_reporting_models.yml
diff --git a/packages.yml b/packages.yml
index 2dcc611..c548c29 100644
--- a/packages.yml
+++ b/packages.yml
@@ -24,4 +24,7 @@ packages:
version: [">=0.2.0", "<0.3.0"]
- package: fivetran/twitter_ads
- version: [">=0.5.0", "<0.6.0"]
\ No newline at end of file
+ version: [">=0.5.0", "<0.6.0"]
+
+ - package: dbt-labs/metrics
+ version: [">=0.3.0", "<0.4.0"]
From d7db6d18af7f14796e7d14d3afd2c319b0e78f3a Mon Sep 17 00:00:00 2001
From: Jamie Rodriguez <65564846+fivetran-jamie@users.noreply.github.com>
Date: Mon, 12 Sep 2022 14:44:17 -0700
Subject: [PATCH 02/11] metrics
---
models/ad_reporting__ad_report.sql | 2 +-
models/ad_reporting_metrics.yml | 28 ++++++++++++++--------------
packages.yml | 3 ---
3 files changed, 15 insertions(+), 18 deletions(-)
diff --git a/models/ad_reporting__ad_report.sql b/models/ad_reporting__ad_report.sql
index ff2bfde..8462c21 100644
--- a/models/ad_reporting__ad_report.sql
+++ b/models/ad_reporting__ad_report.sql
@@ -10,7 +10,7 @@ with base as (
aggregated as (
select
- date_day,
+ date_day as date_day_test,
platform,
account_id,
account_name,
diff --git a/models/ad_reporting_metrics.yml b/models/ad_reporting_metrics.yml
index be79dbe..91f874b 100644
--- a/models/ad_reporting_metrics.yml
+++ b/models/ad_reporting_metrics.yml
@@ -7,13 +7,14 @@ metrics:
type: sum
sql: spend
+ description: Total spend (in currency of individual platforms)
- timestamp: date_day
+ timestamp: date_day_test
time_grains: [day, week, month]
dimensions:
- platform
- - campaign_id # do i include name?
+ - campaign_id
- campaign_name
- ad_group_id
- ad_group_name
@@ -28,8 +29,9 @@ metrics:
type: sum
sql: clicks
+ description: Total clicks
- timestamp: date_day
+ timestamp: date_day_test
time_grains: [day, week, month]
dimensions:
@@ -46,11 +48,12 @@ metrics:
- name: impressions
label: Ad impressions (Fivetran)
model: ref('ad_reporting__ad_report')
+ description: Total impressions
type: sum
sql: impressions
- timestamp: date_day
+ timestamp: date_day_test
time_grains: [day, week, month]
dimensions:
@@ -66,12 +69,12 @@ metrics:
- name: cost_per_click
label: Average ad cost per click (Fivetran)
- model: ref('ad_reporting__ad_report')
+ description: The ratio of spend to clicks
type: expression
sql: "{{ metric('spend') }} / {{ metric('clicks') }}"
- timestamp: date_day
+ timestamp: date_day_test
time_grains: [day, week, month]
dimensions:
@@ -92,13 +95,12 @@ metrics:
- name: bounce_rate
label: Average Ad Bounce Rate (Fivetran)
- model: ref('ad_reporting__ad_report')
description: Percentage of impressions that did not convert into clicks.
type: expression
sql: "({{ metric('impressions') }} - {{ metric('clicks') }}) / {{ metric('impressions') }}"
- timestamp: date_day
+ timestamp: date_day_test
time_grains: [day, week, month]
dimensions:
@@ -119,13 +121,12 @@ metrics:
- name: clickthrough_rate
label: Ad Clickthrough Rate (Fivetran)
- model: ref('ad_reporting__ad_report')
description: Percentage of impressions that did convert into clicks.
type: expression
sql: "{{ metric('clicks') }} / {{ metric('impressions') }}"
- timestamp: date_day
+ timestamp: date_day_test
time_grains: [day, week, month]
dimensions:
@@ -139,7 +140,6 @@ metrics:
- account_id
- account_name
- # maybe add a filter around the spend?
filters:
- field: impressions
operator: '>'
@@ -153,7 +153,7 @@ metrics:
type: count_distinct
sql: ad_id
- timestamp: date_day
+ timestamp: date_day_test
time_grains: [day, week, month]
dimensions:
@@ -178,7 +178,7 @@ metrics:
type: average
sql: spend
- timestamp: date_day
+ timestamp: date_day_test
time_grains: [week, month]
dimensions:
@@ -203,7 +203,7 @@ metrics:
type: average
sql: spend
- timestamp: date_day
+ timestamp: date_day_test
time_grains: [week, month]
dimensions:
diff --git a/packages.yml b/packages.yml
index c548c29..e059d8e 100644
--- a/packages.yml
+++ b/packages.yml
@@ -25,6 +25,3 @@ packages:
- package: fivetran/twitter_ads
version: [">=0.5.0", "<0.6.0"]
-
- - package: dbt-labs/metrics
- version: [">=0.3.0", "<0.4.0"]
From ae4ee45d7faac552437b8061b142d5884ee3efd9 Mon Sep 17 00:00:00 2001
From: Jamie Rodriguez <65564846+fivetran-jamie@users.noreply.github.com>
Date: Mon, 19 Sep 2022 12:30:44 -0700
Subject: [PATCH 03/11] readme
---
README.md | 39 +++++++++++++++++++++++++++++++
integration_tests/dbt_project.yml | 2 +-
packages.yml | 3 +++
3 files changed, 43 insertions(+), 1 deletion(-)
diff --git a/README.md b/README.md
index db80c12..41d4c63 100644
--- a/README.md
+++ b/README.md
@@ -209,6 +209,42 @@ Fivetran offers the ability for you to orchestrate your dbt project through [Fiv
+## (Optional) Step 8: Use predefined Metrics & 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:
+- Spend
+- Impressions
+- Clicks
+- Cost per click
+- Clickthrough rate
+- Bounce rate
+- Count of active ads
+- 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/metrics/models/ad_reporting_metrics.yml).
+
+To utilize these metrics in your code, refer to the [dbt metrics package](https://github.com/dbt-labs/dbt_metrics) 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')
+ ]
+) }}
+```
+
+
+
+
# 🔍 Does this package have dependencies?
This dbt package is dependent on the following dbt packages. For more information on the below packages, refer to the [dbt hub](https://hub.getdbt.com/) site.
> **If you have any of these dependent packages in your own `packages.yml` I highly recommend you remove them to ensure there are no package version conflicts.**
@@ -277,6 +313,9 @@ packages:
- package: fivetran/tiktok_ads_source
version: [">=0.2.0", "<0.3.0"]
+
+ - package: dbt-labs/metrics
+ version: [">=0.3.0", "<0.4.0"]
```
# 🙌 How is this package maintained and can I contribute?
## Package Maintenance
diff --git a/integration_tests/dbt_project.yml b/integration_tests/dbt_project.yml
index aa90b52..0734a8c 100644
--- a/integration_tests/dbt_project.yml
+++ b/integration_tests/dbt_project.yml
@@ -9,7 +9,7 @@ dispatch:
vars:
apple_search_ads__using_search_terms: True
- twitter_ads__using_keywords: False
+ twitter_ads__using_keywords: True
apple_search_ads_source:
apple_search_ads_schema: ad_reporting_integration_tests_v1
apple_search_ads_organization_identifier: "apple_search_organization_data"
diff --git a/packages.yml b/packages.yml
index e059d8e..e2b12b1 100644
--- a/packages.yml
+++ b/packages.yml
@@ -25,3 +25,6 @@ packages:
- package: fivetran/twitter_ads
version: [">=0.5.0", "<0.6.0"]
+
+ - package: dbt-labs/metrics
+ version: [">=0.3.0", "<0.4.0"]
\ No newline at end of file
From d7fb030ce7833a29dfc03d0a79864b985f2e2051 Mon Sep 17 00:00:00 2001
From: Jamie Rodriguez <65564846+fivetran-jamie@users.noreply.github.com>
Date: Mon, 19 Sep 2022 14:52:06 -0700
Subject: [PATCH 04/11] removed filters on expression type metrics
---
models/ad_reporting_metrics.yml | 15 ---------------
1 file changed, 15 deletions(-)
diff --git a/models/ad_reporting_metrics.yml b/models/ad_reporting_metrics.yml
index 91f874b..aeeac5a 100644
--- a/models/ad_reporting_metrics.yml
+++ b/models/ad_reporting_metrics.yml
@@ -88,11 +88,6 @@ metrics:
- account_id
- account_name
- filters:
- - field: clicks
- operator: '>'
- value: '0'
-
- name: bounce_rate
label: Average Ad Bounce Rate (Fivetran)
description: Percentage of impressions that did not convert into clicks.
@@ -114,11 +109,6 @@ metrics:
- account_id
- account_name
- filters:
- - field: impressions
- operator: '>'
- value: '0'
-
- name: clickthrough_rate
label: Ad Clickthrough Rate (Fivetran)
description: Percentage of impressions that did convert into clicks.
@@ -139,11 +129,6 @@ metrics:
- ad_name
- account_id
- account_name
-
- filters:
- - field: impressions
- operator: '>'
- value: '0'
- name: active_ads
label: Count of Active Ads (Fivetran)
From 9157da1bc9763db3fbfee300afd12aa7d9a16c14 Mon Sep 17 00:00:00 2001
From: Jamie Rodriguez <65564846+fivetran-jamie@users.noreply.github.com>
Date: Mon, 19 Sep 2022 14:53:04 -0700
Subject: [PATCH 05/11] change integration tests
---
integration_tests/dbt_project.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/integration_tests/dbt_project.yml b/integration_tests/dbt_project.yml
index 0734a8c..aa90b52 100644
--- a/integration_tests/dbt_project.yml
+++ b/integration_tests/dbt_project.yml
@@ -9,7 +9,7 @@ dispatch:
vars:
apple_search_ads__using_search_terms: True
- twitter_ads__using_keywords: True
+ twitter_ads__using_keywords: False
apple_search_ads_source:
apple_search_ads_schema: ad_reporting_integration_tests_v1
apple_search_ads_organization_identifier: "apple_search_organization_data"
From 2e1fcf57b07efbfa74d27a5eda0d42c714a8273b Mon Sep 17 00:00:00 2001
From: Jamie Rodriguez <65564846+fivetran-jamie@users.noreply.github.com>
Date: Mon, 19 Sep 2022 14:55:26 -0700
Subject: [PATCH 06/11] fix requirements.txt for circle ci
---
integration_tests/requirements.txt | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/integration_tests/requirements.txt b/integration_tests/requirements.txt
index 5c612de..4913903 100644
--- a/integration_tests/requirements.txt
+++ b/integration_tests/requirements.txt
@@ -1,6 +1,6 @@
-dbt-snowflake~=1.0.0
-dbt-bigquery~=1.0.0
-dbt-redshift~=1.0.0
-dbt-postgres~=1.0.0
-dbt-spark~=1.0.0
-dbt-spark[PyHive]~=1.0.0
\ No newline at end of file
+dbt-snowflake>=1.0.0
+dbt-bigquery>=1.0.0
+dbt-redshift>=1.0.0
+dbt-postgres>=1.0.0
+dbt-spark>=1.0.0
+dbt-spark[PyHive]>=1.0.0
\ No newline at end of file
From 5dee3afcb179fd77131c9b1e68bb6cced9d61d53 Mon Sep 17 00:00:00 2001
From: Jamie Rodriguez <65564846+fivetran-jamie@users.noreply.github.com>
Date: Mon, 19 Sep 2022 15:05:37 -0700
Subject: [PATCH 07/11] versions
---
CHANGELOG.md | 11 +++++++++++
README.md | 2 +-
dbt_project.yml | 2 +-
integration_tests/dbt_project.yml | 2 +-
4 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index bbfd434..51c27a4 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,14 @@
+# dbt_ad_reporting v1.0.1
+
+## 🎉 Feature Enhancements 🎉
+The package now includes a set of pre-defined [metrics](https://docs.getdbt.com/docs/building-a-dbt-project/metrics) related to clicks, impressions, and spend (definitions [here](https://github.com/fivetran/dbt_ad_reporting/blob/main/models/ad_reporting_metrics.yml)).
+
+Refer to the [README](https://github.com/fivetran/dbt_ad_reporting#optional-step-8-use-predefined-metrics--the-dbt-semantic-layer) for the included metrics and instructions on how to use them.
+
+Note: This introduces a dependency on the [dbt metrics package](https://github.com/dbt-labs/dbt_metrics).
+
+[PR #57](https://github.com/fivetran/dbt_ad_reporting/pull/57)
+
# dbt_ad_reporting v1.0.0
## 🚨 Breaking Changes 🚨
[PR #54](https://github.com/fivetran/dbt_ad_reporting/pull/54) incorporates these breaking changes:
diff --git a/README.md b/README.md
index 41d4c63..15a5b00 100644
--- a/README.md
+++ b/README.md
@@ -223,7 +223,7 @@ 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/metrics/models/ad_reporting_metrics.yml).
+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 utilize these metrics in your code, refer to the [dbt metrics package](https://github.com/dbt-labs/dbt_metrics) and the example below:
```sql
diff --git a/dbt_project.yml b/dbt_project.yml
index abc505f..e3624fb 100644
--- a/dbt_project.yml
+++ b/dbt_project.yml
@@ -1,5 +1,5 @@
name: 'ad_reporting'
-version: '1.0.0'
+version: '1.0.1'
config-version: 2
require-dbt-version: [">=1.0.0", "<2.0.0"]
diff --git a/integration_tests/dbt_project.yml b/integration_tests/dbt_project.yml
index aa90b52..d9d44e3 100644
--- a/integration_tests/dbt_project.yml
+++ b/integration_tests/dbt_project.yml
@@ -1,5 +1,5 @@
name: 'ad_reporting_integration_tests'
-version: '1.0.0'
+version: '1.0.1'
profile: 'integration_tests'
config-version: 2
From 4fa730c93d0739cf0be053b197cdbb3ee30c3683 Mon Sep 17 00:00:00 2001
From: Jamie Rodriguez <65564846+fivetran-jamie@users.noreply.github.com>
Date: Fri, 23 Sep 2022 13:37:16 -0700
Subject: [PATCH 08/11] readme
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 15a5b00..218626b 100644
--- a/README.md
+++ b/README.md
@@ -209,7 +209,7 @@ Fivetran offers the ability for you to orchestrate your dbt project through [Fiv
-## (Optional) Step 8: Use predefined Metrics & the dbt Semantic Layer
+## (Optional) Step 8: Use predefined Metrics
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:
From 3398f07c74091a41faef28d49e5959366ccdfae4 Mon Sep 17 00:00:00 2001
From: Jamie Rodriguez <65564846+fivetran-jamie@users.noreply.github.com>
Date: Tue, 27 Sep 2022 14:01:04 -0700
Subject: [PATCH 09/11] remove metrics dep
---
CHANGELOG.md | 4 ++--
README.md | 13 +++++++++----
models/ad_reporting__ad_report.sql | 2 +-
models/ad_reporting_metrics.yml | 18 +++++++++---------
packages.yml | 5 +----
5 files changed, 22 insertions(+), 20 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 51c27a4..0690151 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -3,9 +3,9 @@
## 🎉 Feature Enhancements 🎉
The package now includes a set of pre-defined [metrics](https://docs.getdbt.com/docs/building-a-dbt-project/metrics) related to clicks, impressions, and spend (definitions [here](https://github.com/fivetran/dbt_ad_reporting/blob/main/models/ad_reporting_metrics.yml)).
-Refer to the [README](https://github.com/fivetran/dbt_ad_reporting#optional-step-8-use-predefined-metrics--the-dbt-semantic-layer) for the included metrics and instructions on how to use them.
+Refer to the [README](https://github.com/fivetran/dbt_ad_reporting#optional-step-8-use-predefined-metrics) for the included metrics and instructions on how to use them.
-Note: This introduces a dependency on the [dbt metrics package](https://github.com/dbt-labs/dbt_metrics).
+Note: This requires you to manually add a dependency on the [dbt metrics package](https://github.com/dbt-labs/dbt_metrics) to use.
[PR #57](https://github.com/fivetran/dbt_ad_reporting/pull/57)
diff --git a/README.md b/README.md
index 218626b..a0dbf50 100644
--- a/README.md
+++ b/README.md
@@ -225,7 +225,15 @@ On top of the `ad_reporting__ad_report` final model, the Ad Reporting dbt packag
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 utilize these metrics in your code, refer to the [dbt metrics package](https://github.com/dbt-labs/dbt_metrics) and the example below:
+To use dbt Metrics, add the [dbt metrics package](https://github.com/dbt-labs/dbt_metrics) to your project's `packages.yml` file:
+```yml
+packages:
+ - package: dbt-labs/metrics
+ version: [">=0.3.0", "<0.4.0"]
+```
+> **Note**: The Metrics package has stricter dbt version requirements. As of today, the latest version of Metrics (v0.3.5) requires dbt `[">=1.2.0-a1", "<2.0.0"]`.
+
+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(
@@ -313,9 +321,6 @@ packages:
- package: fivetran/tiktok_ads_source
version: [">=0.2.0", "<0.3.0"]
-
- - package: dbt-labs/metrics
- version: [">=0.3.0", "<0.4.0"]
```
# 🙌 How is this package maintained and can I contribute?
## Package Maintenance
diff --git a/models/ad_reporting__ad_report.sql b/models/ad_reporting__ad_report.sql
index 8462c21..ff2bfde 100644
--- a/models/ad_reporting__ad_report.sql
+++ b/models/ad_reporting__ad_report.sql
@@ -10,7 +10,7 @@ with base as (
aggregated as (
select
- date_day as date_day_test,
+ date_day,
platform,
account_id,
account_name,
diff --git a/models/ad_reporting_metrics.yml b/models/ad_reporting_metrics.yml
index aeeac5a..7b514eb 100644
--- a/models/ad_reporting_metrics.yml
+++ b/models/ad_reporting_metrics.yml
@@ -9,7 +9,7 @@ metrics:
sql: spend
description: Total spend (in currency of individual platforms)
- timestamp: date_day_test
+ timestamp: date_day
time_grains: [day, week, month]
dimensions:
@@ -31,7 +31,7 @@ metrics:
sql: clicks
description: Total clicks
- timestamp: date_day_test
+ timestamp: date_day
time_grains: [day, week, month]
dimensions:
@@ -53,7 +53,7 @@ metrics:
type: sum
sql: impressions
- timestamp: date_day_test
+ timestamp: date_day
time_grains: [day, week, month]
dimensions:
@@ -74,7 +74,7 @@ metrics:
type: expression
sql: "{{ metric('spend') }} / {{ metric('clicks') }}"
- timestamp: date_day_test
+ timestamp: date_day
time_grains: [day, week, month]
dimensions:
@@ -95,7 +95,7 @@ metrics:
type: expression
sql: "({{ metric('impressions') }} - {{ metric('clicks') }}) / {{ metric('impressions') }}"
- timestamp: date_day_test
+ timestamp: date_day
time_grains: [day, week, month]
dimensions:
@@ -116,7 +116,7 @@ metrics:
type: expression
sql: "{{ metric('clicks') }} / {{ metric('impressions') }}"
- timestamp: date_day_test
+ timestamp: date_day
time_grains: [day, week, month]
dimensions:
@@ -138,7 +138,7 @@ metrics:
type: count_distinct
sql: ad_id
- timestamp: date_day_test
+ timestamp: date_day
time_grains: [day, week, month]
dimensions:
@@ -163,7 +163,7 @@ metrics:
type: average
sql: spend
- timestamp: date_day_test
+ timestamp: date_day
time_grains: [week, month]
dimensions:
@@ -188,7 +188,7 @@ metrics:
type: average
sql: spend
- timestamp: date_day_test
+ timestamp: date_day
time_grains: [week, month]
dimensions:
diff --git a/packages.yml b/packages.yml
index e2b12b1..2dcc611 100644
--- a/packages.yml
+++ b/packages.yml
@@ -24,7 +24,4 @@ packages:
version: [">=0.2.0", "<0.3.0"]
- package: fivetran/twitter_ads
- version: [">=0.5.0", "<0.6.0"]
-
- - package: dbt-labs/metrics
- version: [">=0.3.0", "<0.4.0"]
\ No newline at end of file
+ version: [">=0.5.0", "<0.6.0"]
\ No newline at end of file
From 5f368950b8f3279849ca62f4498c1ce4b7adb786 Mon Sep 17 00:00:00 2001
From: Jamie Rodriguez <65564846+fivetran-jamie@users.noreply.github.com>
Date: Tue, 27 Sep 2022 14:50:42 -0700
Subject: [PATCH 10/11] reformat changelog
---
CHANGELOG.md | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 0690151..ca2b4f3 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,13 +1,10 @@
# dbt_ad_reporting v1.0.1
## 🎉 Feature Enhancements 🎉
-The package now includes a set of pre-defined [metrics](https://docs.getdbt.com/docs/building-a-dbt-project/metrics) related to clicks, impressions, and spend (definitions [here](https://github.com/fivetran/dbt_ad_reporting/blob/main/models/ad_reporting_metrics.yml)).
-
-Refer to the [README](https://github.com/fivetran/dbt_ad_reporting#optional-step-8-use-predefined-metrics) for the included metrics and instructions on how to use them.
-
-Note: This requires you to manually add a dependency on the [dbt metrics package](https://github.com/dbt-labs/dbt_metrics) to use.
-
-[PR #57](https://github.com/fivetran/dbt_ad_reporting/pull/57)
+[PR #57](https://github.com/fivetran/dbt_ad_reporting/pull/57) incorporates these breaking change:
+- The package now includes a set of pre-defined [metrics](https://docs.getdbt.com/docs/building-a-dbt-project/metrics) related to clicks, impressions, and spend (definitions [here](https://github.com/fivetran/dbt_ad_reporting/blob/main/models/ad_reporting_metrics.yml)).
+ - Refer to the [README](https://github.com/fivetran/dbt_ad_reporting#optional-step-8-use-predefined-metrics) for the included metrics and instructions on how to use them.
+ - Note: This requires you to manually add a dependency on the [dbt metrics package](https://github.com/dbt-labs/dbt_metrics) to use.
# dbt_ad_reporting v1.0.0
## 🚨 Breaking Changes 🚨
From 924a9d839f0a17f700ab9ed1eccbc61666c50b8e Mon Sep 17 00:00:00 2001
From: Jamie Rodriguez <65564846+fivetran-jamie@users.noreply.github.com>
Date: Tue, 27 Sep 2022 14:51:57 -0700
Subject: [PATCH 11/11] typo
---
CHANGELOG.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index ca2b4f3..5f62165 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,7 +1,7 @@
# dbt_ad_reporting v1.0.1
## 🎉 Feature Enhancements 🎉
-[PR #57](https://github.com/fivetran/dbt_ad_reporting/pull/57) incorporates these breaking change:
+[PR #57](https://github.com/fivetran/dbt_ad_reporting/pull/57) incorporates the following change:
- The package now includes a set of pre-defined [metrics](https://docs.getdbt.com/docs/building-a-dbt-project/metrics) related to clicks, impressions, and spend (definitions [here](https://github.com/fivetran/dbt_ad_reporting/blob/main/models/ad_reporting_metrics.yml)).
- Refer to the [README](https://github.com/fivetran/dbt_ad_reporting#optional-step-8-use-predefined-metrics) for the included metrics and instructions on how to use them.
- Note: This requires you to manually add a dependency on the [dbt metrics package](https://github.com/dbt-labs/dbt_metrics) to use.