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 user passthrough column to users model and update dependencies #44

Merged
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
3754e57
add user passthrough column to users model
fivetran-reneeli Jul 17, 2024
dfe785d
include event_extension var
fivetran-reneeli Jul 17, 2024
0f093c6
change temp packages deps
fivetran-reneeli Jul 17, 2024
0fb90e7
add the var to run script
fivetran-reneeli Jul 17, 2024
0876ec0
temporarily update deps
fivetran-reneeli Jul 18, 2024
4883d86
versioning
fivetran-reneeli Jul 18, 2024
ae866fd
changelog
fivetran-reneeli Jul 18, 2024
7f45498
updates to docs
fivetran-reneeli Jul 18, 2024
260cc6a
add validation testing
fivetran-reneeli Jul 19, 2024
e7a53a4
fix
fivetran-reneeli Jul 19, 2024
79b3551
schema
fivetran-reneeli Jul 19, 2024
aafbb89
Update README.md
fivetran-reneeli Jul 22, 2024
0c63d7c
up the version, update changelog, move testing schema
fivetran-reneeli Jul 22, 2024
fda5788
Update models/iterable__events.sql
fivetran-reneeli Jul 22, 2024
e5cd253
Update models/intermediate/int_iterable__campaign_event_metrics.sql
fivetran-reneeli Jul 22, 2024
e2c2724
update using_event_extension logic
fivetran-reneeli Jul 22, 2024
9107b7f
updates
fivetran-reneeli Jul 22, 2024
9124cb3
fix validation tests
fivetran-reneeli Jul 23, 2024
e68d5c7
update docs and fix indent
fivetran-reneeli Jul 23, 2024
43e2e19
fix indentation
fivetran-reneeli Jul 23, 2024
a7360a3
change dependency versions
fivetran-reneeli Jul 23, 2024
a48cb0e
Update .buildkite/scripts/run_models.sh
fivetran-reneeli Jul 23, 2024
627b705
docs
fivetran-reneeli Jul 23, 2024
ce3b634
try
fivetran-reneeli Jul 24, 2024
16268d7
try 2
fivetran-reneeli Jul 24, 2024
d30829b
try 3
fivetran-reneeli Jul 24, 2024
50d8ee4
typo
fivetran-reneeli Jul 24, 2024
70615c9
wrong dash?
fivetran-reneeli Jul 24, 2024
069aef1
switch package deps
fivetran-reneeli Jul 24, 2024
dea51ce
remove experiment id from unique tests and make dynamic, and temporar…
fivetran-reneeli Jul 24, 2024
1119d79
Update CHANGELOG.md
fivetran-reneeli Jul 24, 2024
aaba9f8
new schema
fivetran-reneeli Jul 25, 2024
0a9b49e
update to prefix unique
fivetran-reneeli Jul 25, 2024
ebc02f7
docs
fivetran-reneeli Jul 25, 2024
4d156b9
change deps and update changelog
fivetran-reneeli Jul 25, 2024
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 .buildkite/scripts/run_models.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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" --full-refresh
fivetran-reneeli marked this conversation as resolved.
Show resolved Hide resolved
dbt run --vars '{does_table_exist('user_unsubscribed_message_type'): false, does_table_exist('user_unsubscribed_channel'): false}' --target "$db" --full-refresh
dbt test --target "$db"
dbt run-operation fivetran_utils.drop_schemas_automation --target "$db"
2 changes: 2 additions & 0 deletions .quickstart/quickstart.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ table_variables:
- campaign_suppression_list_history
iterable__using_user_unsubscribed_message_type:
- user_unsubscribed_message_type
iterable__using_event_extension:
- event_extension

destination_configurations:
databricks:
Expand Down
13 changes: 10 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
# dbt_iterable v0.RELEASE.RELEASE
# dbt_iterable v0.12.0
[PR #44](https://github.com/fivetran/dbt_iterable/pull/44) includes the following updates:

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd add more about the experiment_id updates (plus the new columns you're adding) in either a Breaking Change section, or in Bug Fixes below, whichever makes more sense. It looks like it's mostly related to the iterable__using_event_extension section, but more context would be helpful since the logic introduced is non-intuitive.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks Avinash, I added more info in Under the Hood for iterable__using_event_extension and the related experiment_id field

## 🚨 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). This will be a breaking change if you choose to disable the `event_extension` table as `experiment_id` will be removed from downstream models. Conversely, if you wish to include the `experiment_id` grain, ensure that `iterable__using_event_extension` is not explicitly set to False.
fivetran-reneeli marked this conversation as resolved.
Show resolved Hide resolved

- 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).
Copy link
Contributor

Choose a reason for hiding this comment

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

This link--https://github.com/fivetran/dbt_iterable/blob/main/README.md#passing-through-additional-fields--does not work as it's in a collapsed section of the README. I'd remove lines 105-106 and test if the hyperlink works on your branch then.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed the collapsed block


## Under the Hood
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added!

- Addition of integrity and consistency validation tests within integration tests pertaining to the `iterable__user_unsubscriptions` model.
- Updated seed data to ensure proper testing of the latest [v0.8.1 `dbt_iterable_source` release](https://github.com/fivetran/dbt_iterable_source/releases/tag/v0.8.1).
- Updates logic in `int_iterable__campaign_event_metrics`, `iterable__events`, and `iterable__user_campaign` to account for the `iterable__using_event_extension` variable being disabled or enabled. If disabled, `experiment_id` will not show up as a grain.
- Addition of integrity and consistency validation tests within integration tests pertaining to the `iterable__user_unsubscriptions`, `iterable__campaigns`, `iterable__events`, `iterable__user_campaign`, and `iterable_users` models.
- Updated seed data to ensure proper testing of the latest [v0.8.1 `dbt_iterable_source` release](https://github.com/fivetran/dbt_iterable_source/releases/tag/v0.8.1) in addition to testing of the pass_through column features.
- Updated [pull request and issue templates](https://github.com/fivetran/dbt_iterable_source/tree/v0.8.1/.github).
- Included auto-releaser GitHub Actions workflow to automate future releases.

Expand Down
12 changes: 5 additions & 7 deletions README.md
Copy link
Contributor

Choose a reason for hiding this comment

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

@fivetran-reneeli You will need to add the var iterable__using_event_extension to the yml section in step 4.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added

Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah thank you, updated

Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ Include the following Iterable package version in your `packages.yml` file.
```yaml
packages:
- package: fivetran/iterable
version: [">=0.11.0", "<0.12.0"]
version: [">=0.12.0", "<0.13.0"]
```
## Step 3: Define database and schema variables
By default, this package runs using your destination and the `iterable` schema of your [target database](https://docs.getdbt.com/docs/running-a-dbt-project/using-the-command-line-interface/configure-your-profile). If this is not where your Iterable data is located (for example, if your Iterable schema is named `iterable_fivetran`), add the following configuration to your root `dbt_project.yml` file:
Expand All @@ -97,19 +97,18 @@ vars:
iterable__using_campaign_label_history: false # default is true
iterable__using_user_unsubscribed_message_type_history: false # default is true
iterable__using_campaign_suppression_list_history: false # default is true
iterable__using_event_extension: false # default is true
```



## (Optional) Step 5: Additional configurations
<details><summary>Expand for details</summary>
<br>

### Passing Through Additional Fields

This package includes fields we judged were standard across Iterable users. However, the Fivetran connector allows for additional columns to be brought through in the `event_extension` and `user_history` objects. Therefore, if you wish to bring them through, leverage our passthrough column variables.
This package includes fields we judged were standard across Iterable users. However, the Fivetran connector allows for additional columns to be brought through in the `event_extension` and `user_history` objects. Therefore, if you wish to bring them through, leverage our passthrough column variables. For `event_extension` columns, ensure that `iterable__using_event_extension` is set to True, which is the default.

You will see these additional columns populate in the end `iterable__events` and `iterable__users` models.
You will see these additional columns populate in the end `iterable__list_user_history`, `iterable__events`, and `iterable__users` models.
fivetran-avinash marked this conversation as resolved.
Show resolved Hide resolved

**Notice**: A `dbt run --full-refresh` is required each time these variables are edited.

Expand Down Expand Up @@ -169,7 +168,6 @@ By default, this package refers to the new table (`CAMPAIGN_SUPPRESSION_LIST_HIS
vars:
iterable_campaign_suppression_list_history_identifier: "campaign_supression_list_history"
```
</details>

## (Optional) Step 6: Orchestrate your models with Fivetran Transformations for dbt Core™
<details><summary>Expand for details</summary>
Expand All @@ -191,7 +189,7 @@ packages:
version: [">=1.0.0", "<2.0.0"]

- package: fivetran/iterable_source
version: [">=0.8.0", "<0.9.0"]
version: [">=0.9.0", "<0.10.0"]
```

# 🙌 How is this package maintained and can I contribute?
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: 'iterable'
version: '0.11.0'
version: '0.12.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.

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

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

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: iterable_integration_tests_10
schema: iterable_integration_tests_12
threads: 8
bigquery:
type: bigquery
method: service-account-json
project: 'dbt-package-testing'
schema: iterable_integration_tests_10
schema: iterable_integration_tests_12
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: iterable_integration_tests_10
schema: iterable_integration_tests_12
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: iterable_integration_tests_10
schema: iterable_integration_tests_12
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: iterable_integration_tests_10
schema: iterable_integration_tests_12
threads: 8
token: "{{ env_var('CI_DATABRICKS_DBT_TOKEN') }}"
type: databricks
7 changes: 3 additions & 4 deletions integration_tests/dbt_project.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
config-version: 2
name: 'iterable_integration_tests'
version: '0.11.0'
version: '0.12.0'
profile: 'integration_tests'
vars:
iterable_source:
iterable_schema: iterable_integration_tests_10
iterable_schema: iterable_integration_tests_12
iterable_campaign_history_identifier: "campaign_history_data"
iterable_campaign_label_history_identifier: "campaign_label_history_data"
iterable_campaign_list_history_identifier: "campaign_list_history_data"
Expand All @@ -20,8 +20,7 @@ vars:
iterable_user_unsubscribed_message_type_identifier: "user_unsubscribed_message_type_data"
iterable_user_unsubscribed_channel_history_identifier: "user_unsubscribed_channel_history_data"
iterable_user_unsubscribed_message_type_history_identifier: "user_unsubscribed_message_type_history_data"

## For validation testing. To be commented out before release.

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

Expand Down
51 changes: 51 additions & 0 deletions integration_tests/tests/consistency/consistency_campaigns.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{{ config(
tags="fivetran_validations",
enabled=var('fivetran_validation_tests_enabled', false)
) }}

{% set exclude_fields = ["labels"] %}
{% set fields = dbt_utils.star(from=ref('iterable__campaigns'), except=exclude_fields) %}

-- this test ensures the iterable__campaigns end model matches the prior version
with prod as (
select {{ fields }}
from {{ target.schema }}_iterable_prod.iterable__campaigns
where date(updated_at) < date({{ dbt.current_timestamp() }})
),

dev as (
select {{ fields }}
from {{ target.schema }}_iterable_dev.iterable__campaigns
where date(updated_at) < date({{ dbt.current_timestamp() }})
),

prod_not_in_dev as (
-- rows from prod not found in dev
select * from prod
except distinct
select * from dev
),

dev_not_in_prod as (
-- rows from dev not found in prod
select * from dev
except distinct
select * from prod
),

final as (
select
*,
'from prod' as source
from prod_not_in_dev

union all -- union since we only care if rows are produced

select
*,
'from dev' as source
from dev_not_in_prod
)

select *
from final
47 changes: 47 additions & 0 deletions integration_tests/tests/consistency/consistency_events.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{{ config(
Copy link
Contributor

Choose a reason for hiding this comment

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

I got this error when trying to test this model in the integration_tests validation run:

10:02:09    Database Error in test consistency_events (tests/consistency/consistency_events.sql)
  Queries in EXCEPT DISTINCT have mismatched column count; query 1 has 73 columns, query 2 has 72 columns at [25:5]

This is likely because experiment_id now is being removed in the default version. It shouldn't be too difficult to test that it successfully ran though--can you try and document your process for a successful test here?

Copy link
Contributor Author

@fivetran-reneeli fivetran-reneeli Jul 22, 2024

Choose a reason for hiding this comment

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

Thanks for catching this-- I reran the tests and see the errors now. Actually, experiment_id should be there as default so this was unexpected. This led me to looking into the prod/dev runs and actually the missing column is channel_type. Hmm. I will continuing looking into why this is happening

image

Copy link
Contributor

Choose a reason for hiding this comment

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

@fivetran-reneeli Strange. Can you look in the upstream models and see if they are present there?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks Avinash for helping troubleshoot and realize it was due to a missing comma!

tags="fivetran_validations",
enabled=var('fivetran_validation_tests_enabled', false)
) }}
-- this test ensures the iterable__events end model matches the prior version
with prod as (
select *
from {{ target.schema }}_iterable_prod.iterable__events
where date(created_at) < date({{ dbt.current_timestamp() }})
),

dev as (
select *
from {{ target.schema }}_iterable_dev.iterable__events
where date(created_at) < date({{ dbt.current_timestamp() }})
),

prod_not_in_dev as (
-- rows from prod not found in dev
select * from prod
except distinct
select * from dev
),

dev_not_in_prod as (
-- rows from dev not found in prod
select * from dev
except distinct
select * from prod
),

final as (
select
*,
'from prod' as source
from prod_not_in_dev

union all -- union since we only care if rows are produced

select
*,
'from dev' as source
from dev_not_in_prod
)

select *
from final
47 changes: 47 additions & 0 deletions integration_tests/tests/consistency/consistency_user_campaign.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{{ config(
tags="fivetran_validations",
enabled=var('fivetran_validation_tests_enabled', false)
) }}
-- this test ensures the iterable__user_campaign end model matches the prior version
with prod as (
select *
from {{ target.schema }}_iterable_prod.iterable__user_campaign
where date(first_event_at) < date({{ dbt.current_timestamp() }})
),

dev as (
select *
from {{ target.schema }}_iterable_dev.iterable__user_campaign
where date(first_event_at) < date({{ dbt.current_timestamp() }})
),

prod_not_in_dev as (
-- rows from prod not found in dev
select * from prod
except distinct
select * from dev
),

dev_not_in_prod as (
-- rows from dev not found in prod
select * from dev
except distinct
select * from prod
),

final as (
select
*,
'from prod' as source
from prod_not_in_dev

union all -- union since we only care if rows are produced

select
*,
'from dev' as source
from dev_not_in_prod
)

select *
from final
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,6 @@ final as (

select *
from final
where unique_users_prod != unique_users_dev
where unique_user_records_prod != unique_user_records_dev
and channels_prod != channels_dev
and message_types_prod != message_types_dev
47 changes: 47 additions & 0 deletions integration_tests/tests/consistency/consistency_users.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{{ config(
tags="fivetran_validations",
enabled=var('fivetran_validation_tests_enabled', false)
) }}
-- this test ensures the iterable__users end model matches the prior version
with prod as (
select *
from {{ target.schema }}_iterable_prod.iterable__users
where date(updated_at) < date({{ dbt.current_timestamp() }})
),

dev as (
select *
from {{ target.schema }}_iterable_dev.iterable__users
where date(updated_at) < date({{ dbt.current_timestamp() }})
),

prod_not_in_dev as (
-- rows from prod not found in dev
select * from prod
except distinct
select * from dev
),

dev_not_in_prod as (
-- rows from dev not found in prod
select * from dev
except distinct
select * from prod
),

final as (
select
*,
'from prod' as source
from prod_not_in_dev

union all -- union since we only care if rows are produced

select
*,
'from dev' as source
from dev_not_in_prod
)

select *
from final
Loading