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

Fix: ad creative url parsing--child links #22

Merged
merged 19 commits into from
May 16, 2019

Conversation

axelazaid
Copy link
Contributor

  • built new model fb_ad_creatives__child_links

    • this grabs links from an ad and returns the first instance an ad url contains utm parameters
  • updated existing fb_ad_creatives model that joins to fb_ad_creatives__child_links

    • this allows for all child links to be included in the url field
  • variable ad_creatives__child_links_table created in dbt_project.yml to be enabled/disabled depending on the warehouse

  • Passes on snowflake and redshift

@axelazaid axelazaid requested a review from jthandy March 26, 2019 19:54
Copy link
Member

@jthandy jthandy left a comment

Choose a reason for hiding this comment

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

Left one comment in the code. In addition: why are we only implementing this on Snowflake? If this data exists in Snowflake, then it also exists in Redshift. It seems like we should implement this for both, right? I understand that the SQL on Redshift would be quite different, but I have to imagine that the same transformation is possible...


{% if target.type == 'snowflake' %}

links_joined as (
Copy link
Member

Choose a reason for hiding this comment

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

@axelazaid we can't do this! :) you're in the "default" version of this macro--if you need to do something specific to snowflake, you need to do that using a snowflake version of the macro, just like we do everywhere else. We can never write an if statement like this, it's very bad for maintainability of this code moving forwards.

I'm happy to talk this through with you, it's something i've also discussed with erin and chris recently as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i think i understand where you're coming from, but i'm happy to go through this with you!

Copy link
Member

Choose a reason for hiding this comment

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

@axelazaid this PR is getting a bit stale at this point. Is this still something that you'd like to get merged? at this point, the if/then logic is the blocker here. this would need to be rewritten in order to get the PR merged.

Copy link
Contributor Author

@axelazaid axelazaid Apr 17, 2019

Choose a reason for hiding this comment

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

@jthandy i made those changes last week in this branch. there's still some changes that need to be done on the url-parsing aspect though (related to the most recent pr of coalescing url_tags & url), before this could be looked at again

@axelazaid axelazaid requested a review from jthandy April 19, 2019 19:57
@axelazaid
Copy link
Contributor Author

@jthandy this is ready for another review!

Copy link
Member

@jthandy jthandy left a comment

Choose a reason for hiding this comment

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

This is progress! Thanks for continuing to push forwards here. My feedback is pretty consistent with other feedback that I've given on other package-related PRs: our code needs to be very clean when we're working on packages that will be implemented in dozens or hundreds of different projects. At the moment we're not quite there.


links_joined as (

select

id as creative_id,
Copy link
Member

Choose a reason for hiding this comment

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

you've added a join to this CTE, which now makes it very challenging to tell which fields come from which of the tables that are being joined. please prefix all fields with the table that they're coming from in this situation so that others can understand your code when they read through it!

@@ -8,39 +8,55 @@
{% macro default__stitch_fb_ad_creatives() %}
Copy link
Member

Choose a reason for hiding this comment

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

almost all of the implementation of this model across redshift and snowflake is identical. we should refactor this to make the code more DRY.

@@ -0,0 +1,101 @@
-- There are cases where ads can have multiple links attached to them.
Copy link
Member

Choose a reason for hiding this comment

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

The core logic that you're trying to do across redshift and snowflake is identical here, it's just that Stitch loads the data in differently. My recommendation would be to create a base model that normalizes the schemas across both Redshift and snowflake, and then do the transformation in a single model that doesn't need two different adapters because the underlying data is identical. We can accomplish what you're doing here much more simply and minimize the maintenance burden for future analysts.

@axelazaid axelazaid requested a review from jthandy May 10, 2019 14:23
@jthandy
Copy link
Member

jthandy commented May 16, 2019

@axelazaid if you're confident that this works the various adapters, i'm good to go! I just want to make sure that you're triple-checked that the results are good on top of real data.

@axelazaid
Copy link
Contributor Author

yup! this works 100%. tested on redshift and snowflake :) merging now

@axelazaid axelazaid merged commit 2de1382 into master May 16, 2019
@axelazaid axelazaid deleted the fix/ad-creative-url-parsing branch May 16, 2019 13:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants