Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Add conversion metrics #20

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ dbt_modules/
logs/
dbt_packages/
env/
.DS_Store
.DS_Store
package-lock.yml
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
# dbt_tiktok_ads v0.6.0
[PR #20](https://github.com/fivetran/dbt_tiktok_ads/pull/20) includes the following updates:

# Feature Updates: Conversion Support!
- We have added the following source fields to each `tiktok_ads` end model:
- `real_time_conversion`: Number of times your ad resulted in the optimization event you selected.
- `total_purchase_value`: The total value of purchase events that occurred in your app that were recorded by your measurement partner.
- `total_sales_lead_value`: The monetary worth or potential value assigned to a lead generated through ads.
- `total_conversion_value`: The accumulated value of `total_purchase_value` and `total_sales_lead_value`.

- In the event that you were already passing the above fields in via our [passthrough columns](https://github.com/fivetran/dbt_tiktok_ads?tab=readme-ov-file#passing-through-additional-metrics), the package will dynamically avoid "duplicate column" errors.
> The above new field additions are **breaking changes** for users who were not already bringing in conversion fields via passthrough columns.

## Breaking Changes (in the `dbt_tiktok_ads_source` package)
- Update `conversion` to be an integer rather than a numeric data type, as is the expected behavior of the field. To reflect that data type change, you will need to do a `--full-refresh`.

## Under the Hood
- Created `tiktok_ads_persist_pass_through_columns` macro to ensure that the new conversion fields are backwards compatible with users who have already included them via passthrough fields.
- Added integrity and consistency validation tests within `integration_tests` folder for the transformation models (to be used by maintainers only).

## Contributors
- [Seer Interactive](https://www.seerinteractive.com/?utm_campaign=Fivetran%20%7C%20Models&utm_source=Fivetran&utm_medium=Fivetran%20Documentation)

# dbt_tiktok_ads v0.5.0
[PR #13](https://github.com/fivetran/dbt_tiktok_ads/pull/13) includes the following updates:

Expand Down
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,14 @@ dispatch:
search_order: ['spark_utils', 'dbt_utils']
```

### Step 2: Install the package
Include the following tiktok_ads package version in your `packages.yml` file:
### Step 2: Install the package (skip if also using the `ad_reporting` combo package)
Include the following tiktok_ads package version in your `packages.yml` file _if_ you are not also using the upstream [Ad Reporting combination package](https://github.com/fivetran/dbt_ad_reporting):
> TIP: Check [dbt Hub](https://hub.getdbt.com/) for the latest installation instructions or [read the dbt docs](https://docs.getdbt.com/docs/package-management) for more information on installing packages.

```yaml
packages:
- package: fivetran/tiktok_ads
version: [">=0.5.0", "<0.6.0"]
version: [">=0.6.0", "<0.7.0"]

```
Do **NOT** include the `tiktok_ads_source` package in this file. The transformation package itself has a dependency on it and will install the source package as well.
Expand Down Expand Up @@ -83,9 +84,9 @@ vars:
To connect your multiple schema/database sources to the package models, follow the steps outlined in the [Union Data Defined Sources Configuration](https://github.com/fivetran/dbt_fivetran_utils/tree/releases/v0.4.latest#union_data-source) section of the Fivetran Utils documentation for the union_data macro. This will ensure a proper configuration and correct visualization of connections in the DAG.

#### Passing Through Additional Metrics
By default, this package will select `clicks`, `impressions`, and `cost` from the source reporting tables to store into the staging models. If you would like to pass through additional metrics to the staging models, add the below configurations to your `dbt_project.yml` file. These variables allow for the pass-through fields to be aliased (`alias`) if desired, but not required. Use the below format for declaring the respective pass-through variables:
By default, this package will select `clicks`, `impressions`, `cost` , `conversion`, `real_time_conversion`, `total_purchase_value`, and `total_sales_lead_value` from the source reporting tables to store into the staging models. If you would like to pass through additional metrics to the staging models, add the below configurations to your `dbt_project.yml` file. These variables allow for the pass-through fields to be aliased (`alias`) if desired, but not required. Use the below format for declaring the respective pass-through variables:

> IMPORTANT: Make sure to exercise due diligence when adding metrics to these models. The metrics added by default (taps, impressions, and spend) have been vetted by the Fivetran team, maintaining this package for accuracy. There are metrics included within the source reports, such as metric averages, which may be inaccurately represented at the grain for reports created in this package. You must ensure that whichever metrics you pass through are appropriate to aggregate at the respective reporting levels in this package.
> IMPORTANT: Make sure to exercise due diligence when adding metrics to these models. The metrics added by default (taps, impressions, spend, and various conversion metrics) have been vetted by the Fivetran team, maintaining this package for accuracy. There are metrics included within the source reports, such as metric averages, which may be inaccurately represented at the grain for reports created in this package. You must ensure that whichever metrics you pass through are appropriate to aggregate at the respective reporting levels in this package.

```yml
vars:
Expand Down Expand Up @@ -140,7 +141,7 @@ This dbt package is dependent on the following dbt packages. These dependencies
```yml
packages:
- package: fivetran/tiktok_ads_source
version: [">=0.5.0", "<0.6.0"]
version: [">=0.6.0", "<0.7.0"]

- package: fivetran/fivetran_utils
version: [">=0.4.0", "<0.5.0"]
Expand Down
2 changes: 1 addition & 1 deletion dbt_project.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: 'tiktok_ads'
version: '0.5.0'
version: '0.6.0'
config-version: 2
require-dbt-version: [">=1.3.0", "<2.0.0"]
models:
Expand Down
2 changes: 1 addition & 1 deletion docs/catalog.json

Large diffs are not rendered by default.

55 changes: 14 additions & 41 deletions docs/index.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/manifest.json

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion docs/run_results.json

This file was deleted.

10 changes: 5 additions & 5 deletions integration_tests/ci/sample.profiles.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ integration_tests:
pass: "{{ env_var('CI_REDSHIFT_DBT_PASS') }}"
dbname: "{{ env_var('CI_REDSHIFT_DBT_DBNAME') }}"
port: 5439
schema: tiktok_ads_integration_tests_4
schema: tiktok_ads_integration_tests_5
threads: 8
bigquery:
type: bigquery
method: service-account-json
project: 'dbt-package-testing'
schema: tiktok_ads_integration_tests_4
schema: tiktok_ads_integration_tests_5
threads: 8
keyfile_json: "{{ env_var('GCLOUD_SERVICE_KEY') | as_native }}"
snowflake:
Expand All @@ -33,7 +33,7 @@ integration_tests:
role: "{{ env_var('CI_SNOWFLAKE_DBT_ROLE') }}"
database: "{{ env_var('CI_SNOWFLAKE_DBT_DATABASE') }}"
warehouse: "{{ env_var('CI_SNOWFLAKE_DBT_WAREHOUSE') }}"
schema: tiktok_ads_integration_tests_4
schema: tiktok_ads_integration_tests_5
threads: 8
postgres:
type: postgres
Expand All @@ -42,13 +42,13 @@ integration_tests:
pass: "{{ env_var('CI_POSTGRES_DBT_PASS') }}"
dbname: "{{ env_var('CI_POSTGRES_DBT_DBNAME') }}"
port: 5432
schema: tiktok_ads_integration_tests_4
schema: tiktok_ads_integration_tests_5
threads: 8
databricks:
catalog: "{{ env_var('CI_DATABRICKS_DBT_CATALOG') }}"
host: "{{ env_var('CI_DATABRICKS_DBT_HOST') }}"
http_path: "{{ env_var('CI_DATABRICKS_DBT_HTTP_PATH') }}"
schema: tiktok_ads_integration_tests_4
schema: tiktok_ads_integration_tests_5
threads: 8
token: "{{ env_var('CI_DATABRICKS_DBT_TOKEN') }}"
type: databricks
7 changes: 5 additions & 2 deletions integration_tests/dbt_project.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
name: 'tiktok_ads_integration_tests'
version: '0.5.0'
version: '0.6.0'
profile: 'integration_tests'
config-version: 2

models:
+schema: "tiktok_ads_{{ var('directed_schema','dev') }}"

vars:
tiktok_ads_source:
tiktok_ads_schema: tiktok_ads_integration_tests_4
tiktok_ads_schema: tiktok_ads_integration_tests_5
tiktok_ads_adgroup_history_identifier: "tiktok_adgroup_history_data"
tiktok_ads_ad_history_identifier: "tiktok_ad_history_data"
tiktok_ads_advertiser_identifier: "tiktok_advertiser_data"
Expand Down
2 changes: 1 addition & 1 deletion integration_tests/packages.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
packages:
- local: ../
- local: ../
10 changes: 5 additions & 5 deletions integration_tests/seeds/tiktok_ad_report_hourly_data.csv
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
AD_ID,STAT_TIME_HOUR,COST_PER_CONVERSION,REAL_TIME_CONVERSION,CPC,VIDEO_PLAY_ACTIONS,CONVERSION_RATE,VIDEO_VIEWS_P_75,RESULT,VIDEO_VIEWS_P_50,IMPRESSIONS,COMMENTS,REAL_TIME_COST_PER_RESULT,CONVERSION,REAL_TIME_RESULT,VIDEO_VIEWS_P_100,SHARES,REAL_TIME_CONVERSION_RATE,COST_PER_SECONDARY_GOAL_RESULT,SECONDARY_GOAL_RESULT_RATE,CLICKS,COST_PER_1000_REACHED,VIDEO_VIEWS_P_25,REACH,REAL_TIME_COST_PER_CONVERSION,PROFILE_VISITS_RATE,AVERAGE_VIDEO_PLAY,PROFILE_VISITS,CPM,CTR,VIDEO_WATCHED_2_S,FOLLOWS,RESULT_RATE,VIDEO_WATCHED_6_S,SECONDARY_GOAL_RESULT,COST_PER_RESULT,AVERAGE_VIDEO_PLAY_PER_USER,REAL_TIME_RESULT_RATE,SPEND,LIKES,_FIVETRAN_SYNCED
1,2021-09-15 10:00:00,0,0,0,22,0,2,0,2,23,0,0,0,0,0,0,0,-,-,0,0,22,0,0,0,2.22,0,32.22,0,2,0,0,22,-,0,0,0,2.22,0,2021-09-15 15:56:34.862
2,2021-09-15 10:00:00,0,0,0,33,0,0,0,0,22,0,0,0,0,0,0,0,-,-,0,0,3,0,0,0,2.22,0,2.22,0,2,0,0,2,-,0,0,0,0.22,0,2021-09-15 15:56:34.953
3,2021-09-15 10:00:00,0,0,0,2,0,0,0,0,2,0,0,0,0,0,0,0,-,-,0,0,0,0,0,0,2.22,0,0,0,0,0,0,0,-,0,0,0,0,0,2021-09-15 15:56:34.923
4,2021-09-15 10:00:00,0.22,2,0.22,22,222,2,2,2,22,0,0.22,2,2,2,0,200,-,-,2,0,2,0,0.22,0,2.22,0,22.22,2.22,2,0,100,2,-,0.22,0,222,0.22,2,2021-09-15 15:56:34.950
AD_ID,STAT_TIME_HOUR,COST_PER_CONVERSION,CPC,VIDEO_PLAY_ACTIONS,CONVERSION_RATE,VIDEO_VIEWS_P_75,RESULT,VIDEO_VIEWS_P_50,IMPRESSIONS,COMMENTS,REAL_TIME_COST_PER_RESULT,CONVERSION,REAL_TIME_RESULT,VIDEO_VIEWS_P_100,SHARES,REAL_TIME_CONVERSION_RATE,COST_PER_SECONDARY_GOAL_RESULT,SECONDARY_GOAL_RESULT_RATE,CLICKS,COST_PER_1000_REACHED,VIDEO_VIEWS_P_25,REACH,REAL_TIME_COST_PER_CONVERSION,PROFILE_VISITS_RATE,AVERAGE_VIDEO_PLAY,PROFILE_VISITS,CPM,CTR,VIDEO_WATCHED_2_S,FOLLOWS,RESULT_RATE,VIDEO_WATCHED_6_S,SECONDARY_GOAL_RESULT,COST_PER_RESULT,AVERAGE_VIDEO_PLAY_PER_USER,REAL_TIME_RESULT_RATE,SPEND,LIKES,REAL_TIME_CONVERSION,TOTAL_PURCHASE_VALUE,TOTAL_SALES_LEAD_VALUE,_FIVETRAN_SYNCED
1,2021-09-15 10:00:00,0,0,22,0,2,0,2,23,0,0,0,0,0,0,0,-,-,0,0,22,0,0,0,2.22,0,32.22,0,2,0,0,22,-,0,0,0,2.22,0,0,0.00,0.00,2021-09-15 15:56:34.862
2,2021-09-15 10:00:00,0,0,33,0,0,0,0,22,0,0,0,0,0,0,0,-,-,0,0,3,0,0,0,2.22,0,2.22,0,2,0,0,2,-,0,0,0,0.22,0,0,0.01,0.01,2021-09-15 15:56:34.953
3,2021-09-15 10:00:00,0,0,2,0,0,0,0,2,0,0,0,0,0,0,0,-,-,0,0,0,0,0,0,2.22,0,0,0,0,0,0,0,-,0,0,0,0,0,0,0.00,0.00,2021-09-15 15:56:34.923
4,2021-09-15 10:00:00,0.22,0.22,22,222,2,2,2,22,0,0.22,2,2,2,0,200,-,-,2,0,2,0,0.22,0,2.22,0,22.22,2.22,2,0,100,2,-,0.22,0,222,0.22,2,2,0.00,0.00,2021-09-15 15:56:34.950
10 changes: 5 additions & 5 deletions integration_tests/seeds/tiktok_adgroup_report_hourly_data.csv
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ADGROUP_ID,STAT_TIME_HOUR,COST_PER_CONVERSION,REAL_TIME_CONVERSION,CPC,VIDEO_PLAY_ACTIONS,CONVERSION_RATE,VIDEO_VIEWS_P_75,RESULT,VIDEO_VIEWS_P_50,IMPRESSIONS,COMMENTS,REAL_TIME_COST_PER_RESULT,CONVERSION,REAL_TIME_RESULT,VIDEO_VIEWS_P_100,SHARES,REAL_TIME_CONVERSION_RATE,COST_PER_SECONDARY_GOAL_RESULT,SECONDARY_GOAL_RESULT_RATE,CLICKS,COST_PER_1000_REACHED,VIDEO_VIEWS_P_25,REACH,REAL_TIME_COST_PER_CONVERSION,PROFILE_VISITS_RATE,AVERAGE_VIDEO_PLAY,PROFILE_VISITS,CPM,CTR,VIDEO_WATCHED_2_S,FOLLOWS,RESULT_RATE,VIDEO_WATCHED_6_S,SECONDARY_GOAL_RESULT,COST_PER_RESULT,AVERAGE_VIDEO_PLAY_PER_USER,REAL_TIME_RESULT_RATE,SPEND,LIKES,_FIVETRAN_SYNCED
1,2021-09-15 5:00:00,0,0,1.77,555,0,33,0,38,32,0,0,0,0,3,0,0,-,-,2,18.44,150,333,0,0,5,0,17.99,1.22,333,0,0,133,-,0,4.66,0,7.6,3,2021-09-15 15:57:22.614
2,2021-09-15 7:00:00,1.33,7,0.76,1111,39,33,5,33,3235,0,4.123,5,3,44,0,43.22,-,-,34,0,150,0,1.75,0,3.33,0,13.66,1.44,333,0,36.77,233,-,2.3342,0,38.88,17.22,3,2021-09-15 15:57:22.606
3,2021-09-15 7:00:00,3.23,7,1,2222,33,33,7,443,3235,0,2.353,5,7,55,0,22,-,-,33,0,333,0,4.44,0,4.22,0,11.88,1.55,334,0,34,233,-,3.6212,0,22,25.33,4,2021-09-15 15:57:22.616
4,2021-09-15 4:00:00,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-,-,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-,0,0,0,0,0,2021-09-15 15:57:22.616
ADGROUP_ID,STAT_TIME_HOUR,COST_PER_CONVERSION,CPC,VIDEO_PLAY_ACTIONS,CONVERSION_RATE,VIDEO_VIEWS_P_75,RESULT,VIDEO_VIEWS_P_50,IMPRESSIONS,COMMENTS,REAL_TIME_COST_PER_RESULT,CONVERSION,REAL_TIME_RESULT,VIDEO_VIEWS_P_100,SHARES,REAL_TIME_CONVERSION_RATE,COST_PER_SECONDARY_GOAL_RESULT,SECONDARY_GOAL_RESULT_RATE,CLICKS,COST_PER_1000_REACHED,VIDEO_VIEWS_P_25,REACH,REAL_TIME_COST_PER_CONVERSION,PROFILE_VISITS_RATE,AVERAGE_VIDEO_PLAY,PROFILE_VISITS,CPM,CTR,VIDEO_WATCHED_2_S,FOLLOWS,RESULT_RATE,VIDEO_WATCHED_6_S,SECONDARY_GOAL_RESULT,COST_PER_RESULT,AVERAGE_VIDEO_PLAY_PER_USER,REAL_TIME_RESULT_RATE,SPEND,LIKES,REAL_TIME_CONVERSION,TOTAL_PURCHASE_VALUE,TOTAL_SALES_LEAD_VALUE,_FIVETRAN_SYNCED
1,2021-09-15 5:00:00,0,1.77,555,0,33,0,38,32,0,0,0,0,3,0,0,-,-,2,18.44,150,333,0,0,5,0,17.99,1.22,333,0,0,133,-,0,4.66,0,7.6,3,0,0.00,0.00,2021-09-15 15:57:22.614
2,2021-09-15 7:00:00,1.33,0.76,1111,39,33,5,33,3235,0,4.123,2,3,44,0,43.22,-,-,34,0,150,0,1.75,0,3.33,0,13.66,1.44,333,0,36.77,233,-,2.3342,0,38.88,17.22,3,2,0.01,0.01,2021-09-15 15:57:22.606
3,2021-09-15 7:00:00,3.23,1,2222,33,33,7,443,3235,0,2.353,0,7,55,0,22,-,-,33,0,333,0,4.44,0,4.22,0,11.88,1.55,334,0,34,233,-,3.6212,0,22,25.33,4,0,0.00,0.00,2021-09-15 15:57:22.616
4,2021-09-15 4:00:00,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-,-,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-,0,0,0,0,0,0,0.00,0.00,2021-09-15 15:57:22.616
10 changes: 5 additions & 5 deletions integration_tests/seeds/tiktok_campaign_report_hourly_data.csv
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
CAMPAIGN_ID,STAT_TIME_HOUR,COST_PER_CONVERSION,REAL_TIME_CONVERSION,CPC,VIDEO_PLAY_ACTIONS,CONVERSION_RATE,VIDEO_VIEWS_P_75,RESULT,VIDEO_VIEWS_P_50,IMPRESSIONS,COMMENTS,REAL_TIME_COST_PER_RESULT,CONVERSION,REAL_TIME_RESULT,VIDEO_VIEWS_P_100,SHARES,REAL_TIME_CONVERSION_RATE,COST_PER_SECONDARY_GOAL_RESULT,SECONDARY_GOAL_RESULT_RATE,CLICKS,COST_PER_1000_REACHED,VIDEO_VIEWS_P_25,REACH,REAL_TIME_COST_PER_CONVERSION,PROFILE_VISITS_RATE,AVERAGE_VIDEO_PLAY,PROFILE_VISITS,CPM,CTR,VIDEO_WATCHED_2_S,FOLLOWS,RESULT_RATE,VIDEO_WATCHED_6_S,SECONDARY_GOAL_RESULT,COST_PER_RESULT,AVERAGE_VIDEO_PLAY_PER_USER,REAL_TIME_RESULT_RATE,SPEND,LIKES,_FIVETRAN_SYNCED
1,2021-09-15 5:00:00,0,0,1.88,32322,0,222,222,222,22222,0,3.3235,0,23423,33,0,0,-,-,22,2.234,233,22413,0,0,2.22,0,2.35,0.33,2222,0,22.35,322,-,35.32,2.13,22.22,222.12,22,2021-09-15 15:58:05.904
2,2021-09-15 4:00:00,0,0,0,4,0,0,0,0,4,0,0,0,0,0,0,0,-,-,0,22,1,4,0,0,3.334,0,22,0,2,0,0,2,-,3,2.35,0,0.22,2,2021-09-15 15:58:05.905
3,2021-09-15 8:00:00,2.3,22,2.2,222222,222,222,22,787,12222,0,4.12312,22,33,222,2,22.2,-,-,222,0,2335,0,2.55,0,3.52,0,22.22,0.232,3322,0,33.22,2222,-,2.2222,0,22.2,222.22,22,2021-09-15 15:58:05.903
4,2021-09-15 10:00:00,0,0,0,15,0,1,0,1,22,0,0,0,0,1,0,0,-,-,0,0,2,0,0,0,3.324,0,22,0,3,0,0,4,-,0,0,0,0.232,22,2021-09-15 15:58:05.903
CAMPAIGN_ID,STAT_TIME_HOUR,COST_PER_CONVERSION,CPC,VIDEO_PLAY_ACTIONS,CONVERSION_RATE,VIDEO_VIEWS_P_75,RESULT,VIDEO_VIEWS_P_50,IMPRESSIONS,COMMENTS,REAL_TIME_COST_PER_RESULT,CONVERSION,REAL_TIME_RESULT,VIDEO_VIEWS_P_100,SHARES,REAL_TIME_CONVERSION_RATE,COST_PER_SECONDARY_GOAL_RESULT,SECONDARY_GOAL_RESULT_RATE,CLICKS,COST_PER_1000_REACHED,VIDEO_VIEWS_P_25,REACH,REAL_TIME_COST_PER_CONVERSION,PROFILE_VISITS_RATE,AVERAGE_VIDEO_PLAY,PROFILE_VISITS,CPM,CTR,VIDEO_WATCHED_2_S,FOLLOWS,RESULT_RATE,VIDEO_WATCHED_6_S,SECONDARY_GOAL_RESULT,COST_PER_RESULT,AVERAGE_VIDEO_PLAY_PER_USER,REAL_TIME_RESULT_RATE,SPEND,LIKES,REAL_TIME_CONVERSION,TOTAL_PURCHASE_VALUE,TOTAL_SALES_LEAD_VALUE,_FIVETRAN_SYNCED
1,2021-09-15 5:00:00,0,1.88,32322,0,222,222,222,22222,0,3.3235,0,23423,33,0,0,-,-,22,2.234,233,22413,0,0,2.22,0,2.35,0.33,2222,0,22.35,322,-,35.32,2.13,22.22,222.12,22,0,0.00,0.00,2021-09-15 15:58:05.904
2,2021-09-15 4:00:00,0,0,4,0,0,0,0,4,0,0,0,0,0,0,0,-,-,0,22,1,4,0,0,3.334,0,22,0,2,0,0,2,-,3,2.35,0,0.22,2,0,0.01,0.01,2021-09-15 15:58:05.905
3,2021-09-15 8:00:00,2.3,2.2,222222,222,222,22,787,12222,0,4.12312,2,33,222,2,22.2,-,-,222,0,2335,0,2.55,0,3.52,0,22.22,0.232,3322,0,33.22,2222,-,2.2222,0,22.2,222.22,22,2,0.00,0.0,2021-09-15 15:58:05.903
4,2021-09-15 10:00:00,0,0,15,0,1,0,1,22,0,0,0,0,1,0,0,-,-,0,0,2,0,0,0,3.324,0,22,0,3,0,0,4,-,0,0,0,0.232,22,0,0.00,0.0,2021-09-15 15:58:05.903
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{{ config(
tags="fivetran_validations",
enabled=var('fivetran_validation_tests_enabled', false)
) }}

with prod as (
select
ad_group_id,
sum(clicks) as clicks,
sum(impressions) as impressions,
sum(spend) as spend
from {{ target.schema }}_tiktok_ads_prod.tiktok_ads__ad_group_report
group by 1
),

dev as (
select
ad_group_id,
sum(clicks) as clicks,
sum(impressions) as impressions,
sum(spend) as spend
from {{ target.schema }}_tiktok_ads_dev.tiktok_ads__ad_group_report
group by 1
),

final as (
select
prod.ad_group_id,
prod.clicks as prod_clicks,
dev.clicks as dev_clicks,
prod.impressions as prod_impressions,
dev.impressions as dev_impressions,
prod.spend as prod_spend,
dev.spend as dev_spend
from prod
full outer join dev
on dev.ad_group_id = prod.ad_group_id
)

select *
from final
where
abs(prod_clicks - dev_clicks) >= .01
or abs(prod_impressions - dev_impressions) >= .01
or abs(prod_spend - dev_spend) >= .01
45 changes: 45 additions & 0 deletions integration_tests/tests/consistency/consistency_ad_report.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{{ config(
tags="fivetran_validations",
enabled=var('fivetran_validation_tests_enabled', false)
) }}

with prod as (
select
ad_id,
sum(clicks) as clicks,
sum(impressions) as impressions,
sum(spend) as spend
from {{ target.schema }}_tiktok_ads_prod.tiktok_ads__ad_report
group by 1
),

dev as (
select
ad_id,
sum(clicks) as clicks,
sum(impressions) as impressions,
sum(spend) as spend
from {{ target.schema }}_tiktok_ads_dev.tiktok_ads__ad_report
group by 1
),

final as (
select
prod.ad_id,
prod.clicks as prod_clicks,
dev.clicks as dev_clicks,
prod.impressions as prod_impressions,
dev.impressions as dev_impressions,
prod.spend as prod_spend,
dev.spend as dev_spend
from prod
full outer join dev
on dev.ad_id = prod.ad_id
)

select *
from final
where
abs(prod_clicks - dev_clicks) >= .01
or abs(prod_impressions - dev_impressions) >= .01
or abs(prod_spend - dev_spend) >= .01
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{{ config(
tags="fivetran_validations",
enabled=var('fivetran_validation_tests_enabled', false)
) }}

with prod as (
select
advertiser_id,
sum(clicks) as clicks,
sum(impressions) as impressions,
sum(spend) as spend
from {{ target.schema }}_tiktok_ads_prod.tiktok_ads__advertiser_report
group by 1
),

dev as (
select
advertiser_id,
sum(clicks) as clicks,
sum(impressions) as impressions,
sum(spend) as spend
from {{ target.schema }}_tiktok_ads_dev.tiktok_ads__advertiser_report
group by 1
),

final as (
select
prod.advertiser_id,
prod.clicks as prod_clicks,
dev.clicks as dev_clicks,
prod.impressions as prod_impressions,
dev.impressions as dev_impressions,
prod.spend as prod_spend,
dev.spend as dev_spend
from prod
full outer join dev
on dev.advertiser_id = prod.advertiser_id
)

select *
from final
where
abs(prod_clicks - dev_clicks) >= .01
or abs(prod_impressions - dev_impressions) >= .01
or abs(prod_spend - dev_spend) >= .01
Loading