-
Notifications
You must be signed in to change notification settings - Fork 5
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 user passthrough column to users model and update dependencies #44
add user passthrough column to users model and update dependencies #44
Conversation
will regen docs upon approval |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fivetran-reneeli Awesome job! This is a pretty extensive update with a lot of custom logic you had to implement, so great work in getting it to this point.
Some comments to address before approval. Let me know if you have any questions.
Also, you will need to regenerate docs.
CHANGELOG.md
Outdated
@@ -1,4 +1,9 @@ | |||
# dbt_iterable v0.RELEASE.RELEASE | |||
# dbt_iterable v0.11.1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are changes to when experiment_id
is or is not being brought in this model, plus the new aggregate metrics, which I believe classifies as a schema change. Should we consider making this a breaking change and bumping the version up?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good point-- bumped to breaking change
|
||
## Bug Fixes | ||
- Introduces variable `iterable__using_event_extension` to disable the `event_extension` table and exclude its fields from persisting downstream. This allows the downstream models to run even if the source `event_extension` table does not exist. For more information on how to configure the `iterable__using_event_extension` variable, refer to the [README](https://github.com/fivetran/dbt_iterable/blob/main/README.md#step-4-enablingdisabling-models). | ||
- Persists `user_history` passthrough columns, as stipulated via the `iterable_user_history_pass_through_columns` variable, through to the `iterable__users` model. For more information on how to configure the `iterable_user_history_pass_through_columns` variable, refer to the [README](https://github.com/fivetran/dbt_iterable/blob/main/README.md#passing-through-additional-fields). | ||
|
||
## Under the Hood |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can add more details around the consistency tests you've created here too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added!
integration_tests/dbt_project.yml
Outdated
## For validation testing. To be commented out before release. | ||
models: | ||
+schema: "iterable_{{ var('directed_schema','dev') }}" | ||
# models: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can uncomment this, Buildkite is equipped to handle it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done!
'experiment_id'] %} | ||
, sum( {{ col.name }} ) as {{ col.name }} | ||
{% if col.name|lower not in ['unique_user_key', 'user_id', '_fivetran_user_id', 'user_email', 'user_full_name', 'campaign_id', 'campaign_name', 'recurring_campaign_id', 'recurring_campaign_name', 'first_event_at', 'last_event_at', 'template_id', 'template_name'] %} | ||
{% if col.name|lower == 'experiment_id' %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar note to int_iterable__campaign_events
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added experiment_id back to the exclusion
{% if col.name|lower == 'experiment_id' %} | ||
{% if col.name in user_campaign_columns %} | ||
{% if var('iterable__using_event_extension', True) %} | ||
, sum({{ col.name }}) as {{ col.name }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar note to int_iterable__campaign_events
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
dev as ( | ||
select * | ||
from {{ target.schema }}_iterable_dev.iterable__users | ||
where date(created_at) < date({{ dbt.current_timestamp() }}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
where date(created_at) < date({{ dbt.current_timestamp() }}) | |
where date(updated_at) < date({{ dbt.current_timestamp() }}) |
|
||
{%- set user_campaign_columns = adapter.get_columns_in_relation(ref('iterable__user_campaign')) %} | ||
|
||
{%- set user_campaign_columns = adapter.get_columns_in_relation(ref('iterable__user_campaign')) %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{%- set user_campaign_columns = adapter.get_columns_in_relation(ref('iterable__user_campaign')) %} | |
{%- set user_campaign_columns = adapter.get_columns_in_relation(ref('iterable__user_campaign')) %} |
Co-authored-by: Avinash Kunnath <[email protected]>
Co-authored-by: Avinash Kunnath <[email protected]>
Co-authored-by: Avinash Kunnath <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fivetran-reneeli thanks for applying all these changes! I verified that the validation tests worked as expected.
A few comments left to address (plus another reminder to regenerate the docs) and then you should be good for approval.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reminder to bump the README dbt_iterable
version in lines 76-80, now that it's a breaking change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah thank you, updated
Co-authored-by: Avinash Kunnath <[email protected]>
.buildkite/scripts/run_models.sh
Outdated
@@ -21,7 +21,8 @@ dbt compile --target "$db" | |||
dbt run --target "$db" --full-refresh | |||
dbt run --target "$db" | |||
dbt test --target "$db" | |||
dbt run --vars '{iterable__using_campaign_label_history: false, iterable__using_user_unsubscribed_message_type_history: false, iterable__using_campaign_suppression_list_history: false}' --target "$db" --full-refresh | |||
dbt run --vars '{iterable_user_history_pass_through_columns: [{name: "phone_number_updated_at"}], iterable_event_extension_pass_through_columns: [{name: "web_push_message"}]}' --target "$db" --full-refresh | |||
dbt run --vars '{iterable__using_campaign_label_history: false, iterable__using_user_unsubscribed_message_type_history: false, iterable__using_campaign_suppression_list_history: false, iterable__using_event_extension: false}' --target "$db" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fivetran-avinash this is now failing I think due to needing a full refresh after the variables change. Gonna update the script
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fivetran-reneeli Apologies. See PR approval comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @fivetran-reneeli ! Thanks for addressing all the additional comments! This looks good to go.
Regarding your script issue and your commit history, it looks like I sent a final incorrect comment. My initial recommendation was to add the additional incremental run script after the full refresh. But my last suggestion in Github did indeed remove it. Sorry, that line should remain unchanegd.
Can you test this configuration in Buildkite that runs a full-refresh, then an incremental run, and see if this works:
dbt run --vars '{iterable__using_campaign_label_history: false, iterable__using_user_unsubscribed_message_type_history: false, iterable__using_campaign_suppression_list_history: false, iterable__using_event_extension: false}' --target "$db" —full-refresh
dbt run --vars '{iterable__using_campaign_label_history: false, iterable__using_user_unsubscribed_message_type_history: false, iterable__using_campaign_suppression_list_history: false, iterable__using_event_extension: false}' --target "$db"
Thanks @fivetran-avinash yeah I had figured this was what you meant and I tried that in this commit, while it failed I think it's because I didn't add the vars the second time around. Just pushed this and should be good. Appreciate your review!! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fivetran-reneeli thanks for working through these changes. Please see my comments below to address before this will be ready for release approval.
Additionally, I noticed that dbt test
fails if you have set iterable__using_event_extension
to false
. This is because in the yml where we define the tests we are still including experiment_id
and not catching if the variable is turned on/off.
I recommend it would probably be best to create a surrogate key in the model that defines the uniqueness of the end model (like here in our netsuite model) and make that surrogate key dynamic so we can then test that field in the yml (like we have done here for the same netsuite model).
Lastly, I know this is out of scope for this task, but would you be able to create an issue for us to explore the iterable__events
incremental logic. I did an integrity test on our internal data (albeit our internal data may be incomplete and not emulate a customer environment) and found that the row count for the iterable__events
model does not match the row count of the stg_iterable__event
model following an incremental run (this is present in both dev and prod). It would be great for us to proactively create a ticket for us to explore this in a future update.
…ily move back packages deps to test
Co-authored-by: Joe Markiewicz <[email protected]>
Thanks @fivetran-joemarkiewicz for catching-- I removed experiment_id from anywhere it was included in a unique test and instead created a surrogate key in those models (iterable__user_campaign and iterable__campaigns). Hmm strange about the row counts-- will make issue for that |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fivetran-reneeli thanks for working through this PR. I approved, but have a request to add another CHANGELOG entry for the new surrogate key fields and their purpose for the dynamic uniqueness tests. No need to block release approval, but please make sure that comment is addressed and the packages.yml
is updated before being merged and released. Thanks!
packages.yml
Outdated
# - package: fivetran/iterable_source | ||
# version: [">=0.8.0", "<0.9.0"] | ||
# - local: ../dbt_iterable_source | ||
- git: https://github.com/fivetran/dbt_iterable_source.git |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reminder to update the source range and switch before merge and release
[PR #44](https://github.com/fivetran/dbt_iterable/pull/44) includes the following updates: | ||
|
||
## 🚨 Breaking Changes 🚨 | ||
- Introduces variable `iterable__using_event_extension` to allow the `event_extension` table to be disabled and exclude its field, `experiment_id`, from persisting downstream. This permits the downstream models to run even if the source `event_extension` table does not exist. By default the variable is set to True. If you don't have this table, you will need to set `iterable__using_event_extension` to False. For more information on how to configure the `iterable__using_event_extension` variable, refer to the [README](https://github.com/fivetran/dbt_iterable/blob/main/README.md#step-4-enablingdisabling-models). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You'll also want to add in here that the uniqueness test has been updated to account for instances wheniterable__using_event_extension
is enabled/disabled. It would be good to add what the new surrogate fields are and which models they can be found in.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated!
PR Overview
This PR will address the following Issue/Feature:
#43
and internal ticket
This PR will result in the following new package version: v0.12.0
Non breaking as the default config for event_extension is still true so existing users won't see any changes. And the passthrough columns only add columns, instead of deleting or modifying existing ones.
Please provide the finalized CHANGELOG entry which details the relevant changes included in this PR:
Bug Fixes
iterable__using_event_extension
to disable theevent_extension
table and exclude its fields from persisting downstream. This allows the downstream models to run even if the sourceevent_extension
table does not exist. For more information on how to configure theiterable__using_event_extension
variable, refer to the README.user_history
passthrough columns as stipulated via theiterable_user_history_pass_through_columns
variable through to theiterable__users
model. For more information on how to configure theiterable_user_history_pass_through_columns
variable, refer to the README.Under the Hood
iterable__user_unsubscriptions
model.dbt_iterable_source
release.PR Checklist
Basic Validation
Please acknowledge that you have successfully performed the following commands locally:
Before marking this PR as "ready for review" the following have been applied:
Detailed Validation
Please share any and all of your validation steps:
Variables tried:
If you had to summarize this PR in an emoji, which would it be?
💃