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

add update deduplication when there are multiple entries that updates the #30

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,24 @@ warehouse AS (
clicks,
cost
FROM ${ref("fact_ad_performance_daily")}
),
landing_dedupt AS (
SELECT
ad_id,
date_id,
device,
MAX(account_status) AS account_status,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kingman these columns with MAX() operators to deduplicate are slow changing dimensions, right?

Click, costs, impressions can be set to MAX... to get the latest performance values.
However, statuses we should get the current statuses (check this: https://cloud.google.com/bigquery/docs/google-ads-transfer#query_your_data)

MAX(campaign_status) AS campaign_status,
MAX(adgroup_status) AS adgroup_status,
MAX(ad_status) AS ad_status,
MAX(impressions) AS impressions,
MAX(clicks) AS clicks,
MAX(cost) AS cost
FROM landing
GROUP BY
ad_id,
date_id,
device
)
SELECT
l, w,
Expand All @@ -82,7 +100,7 @@ SELECT
ELSE "NO_ACTION"
END disposition,
CURRENT_TIMESTAMP() AS exec_timestamp
FROM landing l
FROM landing_dedupt l
LEFT JOIN warehouse w ON
l.ad_id = w.ad_id AND
l.date_id = w.date_id AND
Expand Down