Skip to content

Commit

Permalink
Merge pull request #106 from fivetran/release/v0.9.1
Browse files Browse the repository at this point in the history
Release/v0.9.1
  • Loading branch information
fivetran-catfritz authored May 4, 2023
2 parents 7d76e94 + 509fe53 commit 2ec3f8b
Show file tree
Hide file tree
Showing 19 changed files with 148 additions and 65 deletions.
2 changes: 1 addition & 1 deletion .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ steps:
commands: |
bash .buildkite/scripts/run_models.sh redshift
- label: ":bricks: Run Tests - Databricks"
- label: ":databricks: Run Tests - Databricks"
key: "run_dbt_databricks"
plugins:
- docker#v3.13.0:
Expand Down
6 changes: 4 additions & 2 deletions .buildkite/scripts/run_models.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ echo `pwd`
cd integration_tests
dbt deps
dbt seed --target "$db" --full-refresh
dbt compile --target "$db" --select hubspot # source does not compile at this time
dbt run --target "$db" --full-refresh
dbt test --target "$db"
dbt run --vars '{hubspot_marketing_enabled: true, hubspot_sales_enabled: false}' --target "$db" --full-refresh
dbt run --vars '{hubspot_marketing_enabled: true, hubspot_contact_merge_audit_enabled: true, hubspot_sales_enabled: false}' --target "$db" --full-refresh
dbt run --vars '{hubspot_marketing_enabled: false, hubspot_sales_enabled: true}' --target "$db" --full-refresh
dbt run --vars '{hubspot_marketing_enabled: false, hubspot_sales_enabled: false}' --target "$db" --full-refresh
dbt run --vars '{hubspot_marketing_enabled: false, hubspot_sales_enabled: true, hubspot__pass_through_all_columns: true, hubspot_using_all_email_events: false}' --target "$db" --full-refresh
dbt test --target "$db"

dbt run-operation fivetran_utils.drop_schemas_automation --target "$db"
51 changes: 51 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE/maintainer_pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
## PR Overview
**This PR will address the following Issue/Feature:**

**This PR will result in the following new package version:**
<!--- Please add details around your decision for breaking vs non-breaking version upgrade. If this is a breaking change, were backwards-compatible options explored? -->

**Please detail what change(s) this PR introduces and any additional information that should be known during the review of this PR:**

## PR Checklist
### Basic Validation
Please acknowledge that you have successfully performed the following commands locally:
- [ ] dbt compile
- [ ] dbt run –full-refresh
- [ ] dbt run
- [ ] dbt test
- [ ] dbt run –vars (if applicable)

Before marking this PR as "ready for review" the following have been applied:
- [ ] The appropriate issue has been linked and tagged
- [ ] You are assigned to the corresponding issue and this PR
- [ ] BuildKite integration tests are passing

### Detailed Validation
Please acknowledge that the following validation checks have been performed prior to marking this PR as "ready for review":
- [ ] You have validated these changes and assure this PR will address the respective Issue/Feature.
- [ ] You are reasonably confident these changes will not impact any other components of this package or any dependent packages.
- [ ] You have provided details below around the validation steps performed to gain confidence in these changes.
<!--- Provide the steps you took to validate your changes below. -->

### Standard Updates
Please acknowledge that your PR contains the following standard updates:
- Package versioning has been appropriately indexed in the following locations:
- [ ] indexed within dbt_project.yml
- [ ] indexed within integration_tests/dbt_project.yml
- [ ] CHANGELOG has individual entries for each respective change in this PR
<!--- If there is a parallel upstream change, remember to reference the corresponding CHANGELOG as an individual entry. -->
- [ ] README updates have been applied (if applicable)
<!--- Remember to check the following README locations for common updates. →
<!--- Suggested install range (needed for breaking changes) →
<!--- Dependency matrix is appropriately updated (if applicable) →
<!--- New variable documentation (if applicable) -->
- [ ] DECISIONLOG updates have been updated (if applicable)
- [ ] Appropriate yml documentation has been added (if applicable)

### dbt Docs
Please acknowledge that after the above were all completed the below were applied to your branch:
- [ ] docs were regenerated (unless this PR does not include any code or yml updates)

### If you had to summarize this PR in an emoji, which would it be?
<!--- For a complete list of markdown compatible emojis check our this git repo (https://gist.github.com/rxaviers/7360908) -->
:dancer:
51 changes: 16 additions & 35 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,52 +1,33 @@
**Are you a current Fivetran customer?**
<!--- Please tell us your name, title and company -->
**Please provide your name and company**

**What change(s) does this PR introduce?**
<!--- Describe what changes your PR introduces to the package and how to leverage this new feature. -->
**Link the issue/feature request which this PR is meant to address**
<!--- If an issue was not created, please create one first so we may discuss the PR prior to opening one. -->

**Did you update the CHANGELOG?**
**Detail what changes this PR introduces and how this addresses the issue/feature request linked above.**

**How did you validate the changes introduced within this PR?**

**Which warehouse did you use to develop these changes?**

**Did you update the CHANGELOG?**
<!--- Please update the new package version’s CHANGELOG entry detailing the changes included in this PR. -->
<!--- To select a checkbox you simply need to add an "x" with no spaces between the brackets (eg. [x] Yes). -->
- [ ] Yes

**Does this PR introduce a breaking change?**
<!--- Does this PR introduce changes that will cause current package users' jobs to fail or require a `--full-refresh`? -->
<!--- To select a checkbox you simply need to add an "x" with no spaces between the brackets (eg. [x] Yes). -->
- [ ] Yes (please provide breaking change details below.)
- [ ] No (please provide an explanation as to how the change is non-breaking below.)

**Did you update the dbt_project.yml files with the version upgrade (please leverage standard semantic versioning)? (In both your main project and integration_tests)**
**Did you update the dbt_project.yml files with the version upgrade (please leverage standard semantic versioning)? (In both your main project and integration_tests)**
<!--- The dbt_project.yml and the integration_tests/dbt_project.yml files contain the version number. Be sure to upgrade it accordingly -->
<!--- To select a checkbox you simply need to add an "x" with no spaces between the brackets (eg. [x] Yes). -->
- [ ] Yes

**Is this PR in response to a previously created Bug or Feature Request**
<!--- If an Issue was created it is helpful to track the progress by linking it in the PR. -->
<!--- To select a checkbox you simply need to add an "x" with no spaces between the brackets (eg. [x] Yes). -->
- [ ] Yes, Issue/Feature [link bug/feature number here]
- [ ] No

**How did you test the PR changes?**
<!--- Proof of testing is required in order for the PR to be approved. -->
<!--- To check a box, remove the space and insert an x in the box (eg. [x] Buildkite). -->
<!--- To select a checkbox you simply need to add an "x" with no spaces between the brackets (eg. [x] Yes). -->
- [ ] Buildkite <!--- Buildkite testing is only applicable to Fivetran employees. -->
- [ ] Local (please provide additional testing details below)

**Select which warehouse(s) were used to test the PR**
<!--- To check a warehouse remove the space and insert an x in the box (eg. [x] Bigquery). -->
<!--- To select a checkbox you simply need to add an "x" with no spaces between the brackets (eg. [x] Yes). -->
- [ ] BigQuery
- [ ] Redshift
- [ ] Snowflake
- [ ] Postgres
- [ ] Databricks
- [ ] Other (provide details below)

**Provide an emoji that best describes your current mood**
<!--- For a complete list of markdown compatible emojis check our this git repo (https://gist.github.com/rxaviers/7360908) -->
:dancer:

**Feedback**

We are so excited you decided to contribute to the Fivetran community dbt package! We continue to work to improve the packages and would greatly appreciate your [feedback](https://www.surveymonkey.com/r/DQ7K7WW) on our existing dbt packages or what you'd like to see next.

**PR Template**
- [Community Pull Request Template](?expand=1&template=pull_request_template.md) (default)

- [Maintainer Pull Request Template](?expand=1&template=maintainer_pull_request_template.md) (to be used by maintainers)
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
# dbt_hubspot v0.9.1

## 🎉 Feature Updates
- A new variable was added `hubspot_using_all_email_events` to allow package users to remove filtered email events from the `stg_hubspot__email_event` staging model as well as the relevant downstream reporting models. This is crucial for HubSpot users who greatly take advantage of marking events as filtered in order to provide accurate reporting. ([#104](https://github.com/fivetran/dbt_hubspot/pull/104))
- The `hubspot_using_all_email_events` variable is `true` by default. Set the variable to `false` to filter out specified email events in your staging and downstream models. ([#104](https://github.com/fivetran/dbt_hubspot/pull/104))

## 🪲 Bug Fixes
- Introduced new macro `adjust_email_metrics` to prevent failures that may occur when certain tables are disabled or enabled. This macro removes any metrics that are unavailable from the default `email_metrics` list, ensuring that the models runs smoothly. It's worth noting that you can still manually set the email_metrics list as described in the README's [(Optional) Step 5: Additional configurations](https://github.com/fivetran/dbt_hubspot/#optional-step-5-additional-configurations). ([#105](https://github.com/fivetran/dbt_hubspot/pull/105))

## 🚘 Under the Hood
- The `email_event_data.csv` seed file was updated to include events that are listed as `true` for filtered_events. This is to effectively test the above mentioned feature update. ([#104](https://github.com/fivetran/dbt_hubspot/pull/104))
- Included `hubspot_using_all_email_events: false` as a variable declared in the final `run_models.sh` step to ensure our integration tests gain coverage over this new feature and variable. ([#104](https://github.com/fivetran/dbt_hubspot/pull/104))
- See the source package [CHANGELOG](https://github.com/fivetran/dbt_hubspot_source/blob/main/CHANGELOG.md) for updates made to the staging layer in `dbt_hubspot_source v0.9.1`.
- Updated the following models to utilize the `adjust_email_metrics` macro ([#105](https://github.com/fivetran/dbt_hubspot/pull/105)):
- hubspot__contacts
- hubspot__contact_lists
- hubspot__email_campaigns
- int_hubspot__email_metrics__by_contact_list
- Incorporated the new `fivetran_utils.drop_schemas_automation` macro into the end of each Buildkite integration test job. ([#103](https://github.com/fivetran/dbt_hubspot/pull/103))
- Updated the pull request [templates](/.github). ([#103](https://github.com/fivetran/dbt_hubspot/pull/103))

# dbt_hubspot v0.9.0

## 🚨 Breaking Changes 🚨
Expand Down
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,19 @@ Include the following hubspot package version in your `packages.yml` file:
```yaml
packages:
- package: fivetran/hubspot
version: [">=0.9.0", "<0.10.0"]
version: [">=0.9.0", "<0.10.0"] # we recommend using ranges to capture non-breaking changes automatically
```
Do **NOT** include the `hubspot_source` package in this file. The transformation package itself has a dependency on it and will install the source package as well.

### Databricks dispatch configuration
If you are using a Databricks destination with this package, you must add the following (or a variation of the following) dispatch configuration within your `dbt_project.yml`. This is required in order for the package to accurately search for macros within the `dbt-labs/spark_utils` then the `dbt-labs/dbt_utils` packages respectively.
```yml
dispatch:
- macro_namespace: dbt_utils
search_order: ['spark_utils', 'dbt_utils']
```

## Step 3: Define database and schema variables
By default, this package runs using your destination and the `hubspot` schema. If this is not where your hubspot data is (for example, if your hubspot schema is named `hubspot_fivetran`), add the following configuration to your root `dbt_project.yml` file:

Expand Down Expand Up @@ -191,6 +201,12 @@ vars:
- name: "ticket_calculated_field"
transform_sql: "total_field / other_total_field"
```
### Filtering email events
When leveraging email events, HubSpot customers may take advantage of filtering out specified email events. These filtered email events are present within the `stg_hubspot__email_events` model and are identified by the `is_filtered_event` boolean field. By default, these events are included in the staging and downstream models generated from this package. However, if you wish to remove these filtered events you may do so by setting the `hubspot_using_all_email_events` variable to false. See below for exact configurations you may provide in your `dbt_project.yml` file:
```yml
vars:
hubspot_using_all_email_events: false # True by default
```

### Changing the Build Schema
By default this package will build the HubSpot staging models within a schema titled (<target_schema> + `_stg_hubspot`) and HubSpot final models within a schema titled (<target_schema> + `hubspot`) in your target database. If this is not where you would like your modeled HubSpot data to be written to, add the following configuration to your root `dbt_project.yml` file:
Expand Down
3 changes: 1 addition & 2 deletions dbt_project.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: 'hubspot'
version: '0.9.0'
version: '0.9.1'
config-version: 2
require-dbt-version: [">=1.3.0", "<2.0.0"]
vars:
Expand Down Expand Up @@ -41,7 +41,6 @@ vars:
engagement_meeting: "{{ ref('stg_hubspot__engagement_meeting') }}"
engagement_note: "{{ ref('stg_hubspot__engagement_note') }}"
engagement_task: "{{ ref('stg_hubspot__engagement_task') }}"
email_metrics: ['bounces', 'clicks', 'deferrals', 'deliveries', 'drops', 'forwards', 'opens', 'prints', 'spam_reports', 'unsubscribes']
hubspot_contact_merge_audit_enabled: false
models:
hubspot:
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: hubspot_integration_tests_2
schema: hubspot_integration_tests_6
threads: 8
bigquery:
type: bigquery
method: service-account-json
project: 'dbt-package-testing'
schema: hubspot_integration_tests_2
schema: hubspot_integration_tests_6
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: hubspot_integration_tests_2
schema: hubspot_integration_tests_6
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: hubspot_integration_tests_2
schema: hubspot_integration_tests_6
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: hubspot_integration_tests_2
schema: hubspot_integration_tests_6
threads: 2
token: "{{ env_var('CI_DATABRICKS_DBT_TOKEN') }}"
type: databricks
4 changes: 2 additions & 2 deletions integration_tests/dbt_project.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: 'hubspot_integration_tests'
version: '0.8.2'
version: '0.9.1'
profile: 'integration_tests'
config-version: 2
vars:
hubspot_schema: hubspot_integration_tests_2
hubspot_schema: hubspot_integration_tests_6
hubspot_source:
hubspot_service_enabled: true
hubspot_company_property_history_identifier: "company_property_history_data"
Expand Down
6 changes: 3 additions & 3 deletions integration_tests/seeds/email_event_data.csv
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ c4337695-9d10-4bd1-89fe-d468407f28e3,2020-03-16 19:01:11.602,2286,,,2020-03-16 1
a9d93225-97e4-35b0-ae48-cef5c5d96d7a,2020-03-16 19:01:11.598,2286,,,2020-03-16 19:00:50.059,2,,,4727653,2020-03-16 19:00:48.934,c4337695-9d10-4bd1-89fe-d468407f28e3,DELIVERED,,o2wjpPyUfzBfq9OSt9I2NQ==
d1be99bb-0102-321a-829e-0ea6efbaf477,2020-03-16 19:01:11.610,2286,,,2020-03-16 18:59:22.346,2,,,4727653,2020-03-16 18:59:21.254,38628f09-e146-459f-880b-0159cfe55dd2,DELIVERED,,o2wjpPyUfzBfq9OSt9I2NQ==
54b21c61-62fb-3998-b434-e5389ecf6195,2020-03-16 19:01:11.612,2286,,,2020-03-16 18:58:06.531,2,,,4727653,2020-03-16 18:58:05.148,63346e66-0578-4fc7-abda-62ba815c7daa,DELIVERED,,o2wjpPyUfzBfq9OSt9I2NQ==
89067bfe-b6ef-3d09-bc35-cfef5a3e29ae,2020-03-16 19:01:11.596,2286,,,2020-03-16 19:00:50.059,2,,,4727653,2020-03-16 19:00:48.934,c4337695-9d10-4bd1-89fe-d468407f28e3,PROCESSED,,o2wjpPyUfzBfq9OSt9I2NQ==
7b114d43-154d-31f9-810b-713734c25ea8,2020-03-16 19:01:11.613,2286,,,2020-03-16 18:58:06.531,2,,,4727653,2020-03-16 18:58:05.148,63346e66-0578-4fc7-abda-62ba815c7daa,PROCESSED,,o2wjpPyUfzBfq9OSt9I2NQ==
ece508cd-a165-3f4d-9317-b642c62e7907,2020-03-16 19:01:11.611,2286,,,2020-03-16 18:59:22.346,2,,,4727653,2020-03-16 18:59:21.254,38628f09-e146-459f-880b-0159cfe55dd2,PROCESSED,,o2wjpPyUfzBfq9OSt9I2NQ==
89067bfe-b6ef-3d09-bc35-cfef5a3e29ae,2020-03-16 19:01:11.596,2286,,,2020-03-16 19:00:50.059,2,,,4727653,2020-03-16 19:00:48.934,c4337695-9d10-4bd1-89fe-d468407f28e3,PROCESSED,true,o2wjpPyUfzBfq9OSt9I2NQ==
7b114d43-154d-31f9-810b-713734c25ea8,2020-03-16 19:01:11.613,2286,,,2020-03-16 18:58:06.531,2,,,4727653,2020-03-16 18:58:05.148,63346e66-0578-4fc7-abda-62ba815c7daa,PROCESSED,true,o2wjpPyUfzBfq9OSt9I2NQ==
ece508cd-a165-3f4d-9317-b642c62e7907,2020-03-16 19:01:11.611,2286,,,2020-03-16 18:59:22.346,2,,,4727653,2020-03-16 18:59:21.254,38628f09-e146-459f-880b-0159cfe55dd2,PROCESSED,true,o2wjpPyUfzBfq9OSt9I2NQ==
8edbc608-96a9-3318-b34c-806b660ea0ad,2020-04-23 16:25:36.703,2286,,,2020-04-23 16:21:12.604,86863875,,,4727653,2020-04-23 15:55:48.891,e040e9c2-dd3d-4926-9ec3-5ace0834e4fb,OPEN,false,Q5+hDGVJvTBdAVfNDmoNzw==
5c814bf0-bd56-34b0-aea3-9effa51d3756,2020-05-01 21:10:36.803,2286,,,2020-05-01 21:06:36.623,86863875,,,4727653,2020-04-23 15:56:01.733,acd11faf-e62a-40b3-8ad8-edecbfb7463c,OPEN,false,yyFrTbWxnSxiliuJBnxvHQ==
a6e576fa-1b65-388d-9573-50ec0a64db3a,2020-05-04 13:35:36.709,2286,,,2020-05-04 13:32:11.729,86863875,,,4727653,2020-04-23 15:55:58.852,ff6dbb56-fd81-432a-a837-07feec296751,OPEN,false,KG2+j8wAdZtIHY97xIGd+Q==
Expand Down
13 changes: 13 additions & 0 deletions macros/adjust_email_metrics.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{% macro adjust_email_metrics(base_ref, var_name) %}

{% set base_cols = dbt_utils.get_filtered_columns_in_relation(ref(base_ref))|map('lower') %}

{% set default_metrics = ['bounces', 'clicks', 'deferrals', 'deliveries', 'drops', 'forwards', 'opens', 'prints', 'spam_reports', 'unsubscribes'] %}
{% set email_metrics = var(var_name, default_metrics)|map('lower') %}

{# Only keep metrics found in the base ref #}
{% set adjusted_cols = email_metrics|select('in', base_cols)|list %}

{{ return(adjusted_cols) }}

{% endmacro %}
4 changes: 2 additions & 2 deletions models/marketing/hubspot__contact_lists.sql
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ with contact_lists as (
from {{ ref('int_hubspot__email_metrics__by_contact_list') }}

), joined as (

{% set email_metrics = adjust_email_metrics('hubspot__email_sends', 'email_metrics') %}
select
contact_lists.*,
{% for metric in var('email_metrics') %}
{% for metric in email_metrics %}
coalesce(email_metrics.total_{{ metric }}, 0) as total_{{ metric }},
coalesce(email_metrics.total_unique_{{ metric }}, 0) as total_unique_{{ metric }}
{% if not loop.last %},{% endif %}
Expand Down
Loading

0 comments on commit 2ec3f8b

Please sign in to comment.