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

review/jm-initial #1

Closed
wants to merge 3 commits into from
Closed
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
2 changes: 1 addition & 1 deletion .github/workflows/auto-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ on:
jobs:
call-workflow-passing-data:
if: github.event.pull_request.merged
uses: fivetran/dbt_package_automations/.github/workflows/auto-release.yml@feature/auto-releaser
uses: fivetran/dbt_package_automations/.github/workflows/auto-release.yml@main
fivetran-joemarkiewicz marked this conversation as resolved.
Show resolved Hide resolved
secrets: inherit
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ This package models Salesforce Marketing Cloud data from [Fivetran's connector](

The main focus of the package is to transform the core object tables into analytics-ready models:
<!--section="salesforce_marketing_cloud_model"-->
- Materializes [Salesforce Marketing Cloud staging tables](https://fivetran.github.io/dbt_salesforce_marketing_cloud/#!/overview/salesforce_marketing_cloud_source/models/?g_v=1) which leverage data in the format described by [this ERD](https://fivetran.com/docs/applications/salesforce_marketing_cloud/#schemainformation). The staging tables clean, test, and prepare your Salesforce Marketing Cloud data from [Fivetran's connector](https://fivetran.com/docs/applications/salesforce_marketing_cloud_source) for analysis by doing the following:
- Materializes [Salesforce Marketing Cloud staging tables](https://fivetran.github.io/dbt_salesforce_marketing_cloud/#!/overview/salesforce_marketing_cloud_source/models/?g_v=1) which leverage data in the format described by [this ERD](https://fivetran.com/docs/applications/salesforce_marketing_cloud/#schemainformation). The staging tables clean, test, and prepare your Salesforce Marketing Cloud data from [Fivetran's connector](https://fivetran.com/docs/applications/salesforce_marketing_cloud) for analysis by doing the following:
fivetran-joemarkiewicz marked this conversation as resolved.
Show resolved Hide resolved
- Primary keys are renamed from `id` to `<table name>_id`.
- Adds column-level testing where applicable. For example, all primary keys are tested for uniqueness and non-null values.
- Provides insight into your Salesforce Marketing Cloud data across the following grains:
Expand All @@ -28,15 +28,15 @@ The main focus of the package is to transform the core object tables into analyt
<!--section="salesforce_marketing_cloud_model"-->
The following table provides a detailed list of all models materialized within this package by default.
> [!TIP]
> See more details about these models in the package's [dbt docs site](https://fivetran.github.io/dbt_salesforce_marketing_cloud/#!/overview/qualtrics).
> See more details about these models in the package's [dbt docs site](https://fivetran.github.io/dbt_salesforce_marketing_cloud/#!/overview).
fivetran-joemarkiewicz marked this conversation as resolved.
Show resolved Hide resolved

| **model** | **description**|
| --------- | -------------- |
| [salesforce_marketing_cloud__email_overview]() | Each record represents an email with aggregated send and event data for each. |
| [salesforce_marketing_cloud__sends_links]() | Each record represents a link and the corresponding send(s). |
| [salesforce_marketing_cloud__sends_overview]() | Each record represents a send with aggregated event data for each. |
| [salesforce_marketing_cloud__subscriber_lists]() | Each record represents a list and the corresponding subscriber(s). |
| [salesforce_marketing_cloud__subscriber_overview]() | Each record represents a subscriber with aggregated event data for each. |
| [salesforce_marketing_cloud__email_overview]() | Each record represents an email with aggregated send and event data for each. |
| [salesforce_marketing_cloud__sends_links]() | Each record represents a link and the corresponding send(s). |
| [salesforce_marketing_cloud__sends_overview]() | Each record represents a send with aggregated event data for each. |
| [salesforce_marketing_cloud__subscriber_lists]() | Each record represents a list and the corresponding subscriber(s). |
| [salesforce_marketing_cloud__subscriber_overview]() | Each record represents a subscriber with aggregated event data for each. |
fivetran-joemarkiewicz marked this conversation as resolved.
Show resolved Hide resolved
<!--section-end-->

# 🎯 How do I use the dbt package?
Expand Down
3 changes: 2 additions & 1 deletion dbt_project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ models:
+materialized: table
intermediate:
+materialized: ephemeral
+schema: int_sfmc
fivetran-joemarkiewicz marked this conversation as resolved.
Show resolved Hide resolved
+schema: int_sfmc
staging:
+materialized: view
+schema: stg_sfmc


vars:
salesforce_marketing_cloud:
email: "{{ source('salesforce_marketing_cloud','email') }}"
event: "{{ source('salesforce_marketing_cloud','event') }}"
link: "{{ source('salesforce_marketing_cloud','link') }}"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{{
{{
config(
materialized='incremental',
unique_key='event_id',
partition_by={'field': 'event_date', 'data_type': 'date'} if target.type not in ('spark','databricks') else ['event_date'],
cluster_by=['event_date'],
incremental_strategy = 'merge' if target.type not in ('postgres', 'redshift') else 'delete+insert',
incremental_strategy = 'merge' if target.type not in ('postgres', 'redshift') else 'delete+insert',
fivetran-joemarkiewicz marked this conversation as resolved.
Show resolved Hide resolved
file_format = 'delta'
)
}}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-- this is meant to be stand alone since subscribers could belong to multiple lists, and I did not want to do a list agg to include this in the subscriber overview, but open for discussion
-- this is meant to be stand alone since subscribers could belong to multiple lists, and I did not want to do a list agg to include this in the subscriber overview, but open for discussion
fivetran-joemarkiewicz marked this conversation as resolved.
Show resolved Hide resolved
with subscribers as (
select
*,
Expand Down
14 changes: 7 additions & 7 deletions models/salesforce_marketing_cloud__email_overview.sql
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ with emails as (
), sends as (
select *
from {{ ref('stg_salesforce_marketing_cloud__send') }}
where not _fivetran_deleted
where not _fivetran_deleted
fivetran-joemarkiewicz marked this conversation as resolved.
Show resolved Hide resolved

), sends_stats as (
select
Expand All @@ -31,9 +31,9 @@ with emails as (
), sends_aggs as (
select
sends_stats.*,
coalesce(total_unique_opens / nullif(total_emails_sent, 0), 0) as open_rate, --use safe divide in dbt
coalesce(total_unique_clicks / nullif(total_emails_sent, 0), 0) as click_through_rate, --use safe divide in dbt
coalesce(total_unsubscribes / nullif(total_emails_sent, 0), 0) as unsubscribe_rate --use safe divide in dbt
coalesce(total_unique_opens / nullif(total_emails_sent, 0), 0) as open_rate, --use safe divide in dbt
coalesce(total_unique_clicks / nullif(total_emails_sent, 0), 0) as click_through_rate, --use safe divide in dbt
coalesce(total_unsubscribes / nullif(total_emails_sent, 0), 0) as unsubscribe_rate --use safe divide in dbt
fivetran-joemarkiewicz marked this conversation as resolved.
Show resolved Hide resolved
from sends_stats

), events_enhanced as (
Expand Down Expand Up @@ -62,7 +62,7 @@ with emails as (

), joined as (
select
emails.*,
emails.*,
fivetran-joemarkiewicz marked this conversation as resolved.
Show resolved Hide resolved
sends_aggs.total_unique_sends,
sends_aggs.total_emails_sent,
sends_aggs.total_unique_opens,
Expand All @@ -72,8 +72,8 @@ with emails as (
sends_aggs.total_deliveries,
sends_aggs.total_targets,
sends_aggs.total_bounces,
sends_aggs.open_rate, --use safe divide in dbt
sends_aggs.click_through_rate, --use safe divide in dbt
sends_aggs.open_rate, --use safe divide in dbt
sends_aggs.click_through_rate, --use safe divide in dbt
sends_aggs.unsubscribe_rate,
events_stats.total_send_events,
events_stats.total_open_events,
Expand Down
6 changes: 3 additions & 3 deletions models/salesforce_marketing_cloud__sends_links.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
with sends as (
select *
from {{ ref('stg_salesforce_marketing_cloud__send') }}
where not _fivetran_deleted
where not _fivetran_deleted
fivetran-joemarkiewicz marked this conversation as resolved.
Show resolved Hide resolved

), link_sends as (
select *
from {{ ref('stg_salesforce_marketing_cloud__link_send') }}
from {{ ref('stg_salesforce_marketing_cloud__link_send') }}

), links as (
select *
from {{ ref('stg_salesforce_marketing_cloud__link') }}
from {{ ref('stg_salesforce_marketing_cloud__link') }}

), joined as (
select
Expand Down
8 changes: 4 additions & 4 deletions models/salesforce_marketing_cloud__sends_overview.sql
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ with sends as (
), sends_aggs as (
select
sends.*,
coalesce(unique_opens / nullif(number_sent, 0), 0) as open_rate, --use safe divide in dbt
coalesce(unique_clicks / nullif(number_sent, 0), 0) as click_through_rate, --use safe divide in dbt
coalesce(unsubscribes / nullif(number_sent, 0), 0) as unsubscribe_rate --use safe divide in dbt
coalesce(unique_opens / nullif(number_sent, 0), 0) as open_rate, --use safe divide in dbt
coalesce(unique_clicks / nullif(number_sent, 0), 0) as click_through_rate, --use safe divide in dbt
coalesce(unsubscribes / nullif(number_sent, 0), 0) as unsubscribe_rate --use safe divide in dbt
from sends

), events_enhanced as (
Expand All @@ -35,7 +35,7 @@ with sends as (

), joined as (
select
sends_aggs.*,
sends_aggs.*,
fivetran-joemarkiewicz marked this conversation as resolved.
Show resolved Hide resolved
events_stats.total_send_events,
events_stats.total_open_events,
events_stats.total_click_events,
Expand Down
2 changes: 1 addition & 1 deletion models/salesforce_marketing_cloud__subscriber_lists.sql
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ with subscribers as (
from {{ ref('stg_salesforce_marketing_cloud__list_subscriber') }}
where coalesce(_fivetran_active, true)

), lists as ( --make lists optional
), lists as ( --make lists optional
fivetran-joemarkiewicz marked this conversation as resolved.
Show resolved Hide resolved
select *
from {{ ref('stg_salesforce_marketing_cloud__list') }}
where coalesce(_fivetran_active, true)
Expand Down
6 changes: 3 additions & 3 deletions models/staging/stg_salesforce_marketing_cloud__email.sql
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ final as (

select
source_relation,
_fivetran_start,
_fivetran_end,
_fivetran_active,
_fivetran_start,
_fivetran_end,
_fivetran_active,
fivetran-joemarkiewicz marked this conversation as resolved.
Show resolved Hide resolved
_fivetran_synced,
asset_id,
asset_type_id,
Expand Down
2 changes: 1 addition & 1 deletion models/staging/stg_salesforce_marketing_cloud__event.sql
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ final as (

select
source_relation,
_fivetran_deleted,
_fivetran_deleted,
fivetran-joemarkiewicz marked this conversation as resolved.
Show resolved Hide resolved
_fivetran_synced,
batch_id,
bounce_category,
Expand Down