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

Merged deals #135

Merged
merged 28 commits into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
029f7eb
add aggregate merged deals field and rm merged deals from final
fivetran-reneeli Feb 13, 2024
c90839d
update deps
fivetran-reneeli Feb 13, 2024
3afe3fb
update deal stage model
fivetran-reneeli Feb 13, 2024
406d4a3
explicit data type cast in int test, rm utc in seed
fivetran-reneeli Feb 13, 2024
24bff3e
add datatype casting for merged deal id too
fivetran-reneeli Feb 13, 2024
5be9c9c
reduce byte size?
fivetran-reneeli Feb 13, 2024
d4b39a0
mirror merged deal seed data as in source
fivetran-reneeli Feb 14, 2024
3450a24
try new schema and add dbt unique test config
fivetran-reneeli Feb 14, 2024
46cfed1
add remaining unique test configs
fivetran-reneeli Feb 14, 2024
0bc1eb8
changelog
fivetran-reneeli Feb 14, 2024
cdfef06
correct unique test to not null test
fivetran-reneeli Feb 16, 2024
2ba80e6
include merged_deal_enabled config and following documentation and te…
fivetran-reneeli Feb 16, 2024
568bcae
changelog update
fivetran-reneeli Feb 16, 2024
6f70dd1
try new schema
fivetran-reneeli Feb 16, 2024
6cff115
feature/quickstart-yml-add
fivetran-joemarkiewicz Feb 19, 2024
5a9f70a
removal of not needed dupes
fivetran-joemarkiewicz Feb 19, 2024
d5b611c
variable updates
fivetran-joemarkiewicz Feb 19, 2024
c0bd2e6
review notes
fivetran-reneeli Feb 19, 2024
6b229d7
Merge branch 'merged_deals' into feature/quickstart-yml-add
fivetran-reneeli Feb 20, 2024
8e6721b
Merge pull request #136 from fivetran/feature/quickstart-yml-add
fivetran-reneeli Feb 20, 2024
1a1fbeb
quickstart add
fivetran-reneeli Feb 20, 2024
3c930e8
new schema
fivetran-reneeli Feb 20, 2024
d13442f
oops didn't push
fivetran-reneeli Feb 20, 2024
80edb49
Update README.md
fivetran-reneeli Feb 21, 2024
5a39f63
Update models/sales/intermediate/int_hubspot__deals_enhanced.sql
fivetran-reneeli Feb 21, 2024
603204d
update deps
fivetran-reneeli Feb 21, 2024
b157c08
docs
fivetran-reneeli Feb 21, 2024
5be67aa
update changelog and docs
fivetran-reneeli Feb 21, 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
4 changes: 2 additions & 2 deletions .buildkite/scripts/run_models.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ dbt run --target "$db" --vars '{hubspot_service_enabled: true}' --full-refresh
dbt run --target "$db" --vars '{hubspot_service_enabled: true}'
dbt test --target "$db"
dbt run --vars '{hubspot_service_enabled: true, hubspot_marketing_enabled: true, hubspot_sales_enabled: false}' --target "$db" --full-refresh
dbt run --vars '{hubspot_service_enabled: true, hubspot_marketing_enabled: true, hubspot_sales_enabled: false}' --target "$db"
dbt run --vars '{hubspot_service_enabled: true, hubspot_marketing_enabled: true, hubspot_sales_enabled: false, hubspot_merged_deal_enabled: true}' --target "$db"
dbt test --target "$db"
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, hubspot__pass_through_all_columns: true, hubspot_using_all_email_events: false, hubspot_owner_enabled: false}' --target "$db" --full-refresh
dbt run --vars '{hubspot_marketing_enabled: false, hubspot_sales_enabled: true, hubspot_merged_deal_enabled: true, hubspot__pass_through_all_columns: true, hubspot_using_all_email_events: false, hubspot_owner_enabled: false}' --target "$db" --full-refresh
dbt test --target "$db"

dbt run-operation fivetran_utils.drop_schemas_automation --target "$db"
100 changes: 100 additions & 0 deletions .quickstart/quickstart.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
database_key: hubspot_database
schema_key: hubspot_schema

dbt_versions: ">=1.3.0 <2.0.0"

table_variables:
hubspot_contact_enabled:
- contact
hubspot_contact_list_enabled:
- contact_list
hubspot_contact_list_member_enabled:
- contact_list_member
hubspot_contact_property_enabled:
- contact_property_history
hubspot_contact_property_history_enabled:
- contact_property_history
hubspot_email_event_enabled:
- email_campaign
- email_event
hubspot_email_event_bounce_enabled:
- email_event_bounce
hubspot_email_event_click_enabled:
- email_event_click
hubspot_email_event_deferred_enabled:
- email_event_deferred
hubspot_email_event_delivered_enabled:
- email_event_delivered
hubspot_email_event_dropped_enabled:
- email_event_dropped
hubspot_email_event_forward_enabled:
- email_event_forward
hubspot_email_event_open_enabled:
- email_event_open
hubspot_email_event_print_enabled:
- email_event_print
hubspot_email_event_sent_enabled:
- email_event_sent
hubspot_email_event_spam_report_enabled:
- email_event_spam_report
hubspot_email_event_status_change_enabled:
- email_event_status_change
hubspot_contact_merge_audit_enabled:
- contact_merge_audit
hubspot_company_enabled:
- company
hubspot_company_property_history_enabled:
- company_property_history
hubspot_deal_enabled:
- deal
- deal_stage
- deal_pipeline
- deal_pipeline_stage
hubspot_merged_deal_enabled:
- merged_deal
hubspot_deal_company_enabled:
- deal_company
hubspot_deal_contact_enabled:
- deal_contact
hubspot_deal_property_history_enabled:
- deal_property_history
hubspot_engagement_enabled:
- engagement
hubspot_engagement_contact_enabled:
- engagement_contact
hubspot_engagement_company_enabled:
- engagement_company
hubspot_engagement_deal_enabled:
- engagement_deal
hubspot_engagement_call_enabled:
- engagement_call
hubspot_engagement_email_enabled:
- engagement_email
hubspot_engagement_meeting_enabled:
- engagement_meeting
hubspot_engagement_note_enabled:
- engagement_note
hubspot_engagement_task_enabled:
- engagement_task
hubspot_owner_enabled:
- owner
hubspot_property_enabled:
- property
hubspot_property_enabled:
- property_option
hubspot_service_enabled:
- ticket_company
- ticket_contact
- ticket_engagement
- ticket_pipeline_stage
- ticket_pipeline
- ticket_property_history
- ticket
hubspot_ticket_deal_enabled:
- ticket_deal

destination_configurations:
databricks:
dispatch:
- macro_namespace: dbt_utils
search_order: [ 'spark_utils', 'dbt_utils' ]
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
# dbt_hubspot v0.16.0
[PR #135](https://github.com/fivetran/dbt_hubspot/pull/135) includes the following updates:

## 🚨 Breaking Changes 🚨
- Added unique tests on `event_id` for event-based models, `contact_id` for `hubspot__contacts`, and `contact_list_id` for `hubspot__contact_lists`, on the condition the titular fields have not been deleted. We would advise running through these to ensure they work successfully.

## Features
- Updates the `hubspot__deal_stages` and `hubspot__deals` models to remove stale deals that have been merged since into other deals. In addition we've introduced a new field `merged_deal_ids` that lists all historic merged deals for each deal.
- **Please note** you must have the underlying `merged_deals` table to take advantage of the above mentioned merged deal update. This may be enabled by setting `hubspot_merged_deal_enabled` to True (by default this will be False). Also, `hubspot_sales_enabled` and `hubspot_deal_enabled` must not be set to False (by default these are True). See [Step 4 of the README](https://github.com/fivetran/dbt_hubspot#step-4-disable-models-for-non-existent-sources) for more details.

## Variable Bug Fixes
- The following adjustments have been made concerning the `hubspot_contact_enabled` variable:
- The `email_events_joined()` macro now includes conditional logic to include contact information only if the `hubspot_contact_enabled` variable is defined as `true`.
- The `int_hubspot__email_metrics__by_contact_list` model is now dependent on the `hubspot_contact_enabled` variable being defined as `true`.
- The `hubspot__contact_lists` model now takes into consideration the `hubspot_contact_enabled` variable being defined as `true` before joining in email metric information to the contact lists data.
- Modified the config enabled logic within the `hubspot__email_sends` model to be dependent on the `hubspot_email_event_sent_enabled` variable being `true` in addition to the `hubspot_marketing_enabled` and `hubspot_email_event_enabled` variables.

## Under the Hood
- Added quickstart.yml for Quickstart customers.

# dbt_hubspot v0.15.1
[PR #129](https://github.com/fivetran/dbt_hubspot/pull/129) includes the following updates:

Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ Include the following hubspot package version in your `packages.yml` file:
```yaml
packages:
- package: fivetran/hubspot
version: [">=0.15.0", "<0.16.0"] # we recommend using ranges to capture non-breaking changes automatically
version: [">=0.16.0", "<0.17.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.
Expand All @@ -96,7 +96,7 @@ vars:
```

## Step 4: Disable models for non-existent sources
When setting up your Hubspot connection in Fivetran, it is possible that not every table this package expects will be synced. This can occur because you either don't use that functionality in Hubspot or have actively decided to not sync some tables. In order to disable the relevant functionality in the package, you will need to add the relevant variables. By default, all variables are assumed to be `true` (with exception of `hubspot_service_enabled`, `hubspot_ticket_deal_enabled`, and `hubspot_contact_merge_audit_enabled`). You only need to add variables within your root `dbt_project.yml` for the tables you would like to disable or enable respectively:
When setting up your Hubspot connection in Fivetran, it is possible that not every table this package expects will be synced. This can occur because you either don't use that functionality in Hubspot or have actively decided to not sync some tables. In order to disable the relevant functionality in the package, you will need to add the relevant variables. By default, all variables are assumed to be `true` (with exception of `hubspot_service_enabled`, `hubspot_ticket_deal_enabled`, `hubspot_contact_merge_audit_enabled`, and `hubspot_merged_deal_enabled`). You only need to add variables within your root `dbt_project.yml` for the tables you would like to disable or enable respectively:

```yml
vars:
Expand Down Expand Up @@ -131,6 +131,7 @@ vars:
hubspot_company_enabled: false
hubspot_company_property_history_enabled: false # Disables the company property history models
hubspot_deal_enabled: false
hubspot_merged_deal_enabled: true # Enables the merged_deal table, which will be used to filter out merged deals from the final deal models. Note that `hubspot_sales_enabled` and `hubspot_deal_enabled` must not be set to False.
fivetran-reneeli marked this conversation as resolved.
Show resolved Hide resolved
hubspot_deal_company_enabled: false
hubspot_deal_contact_enabled: false
hubspot_deal_property_history_enabled: false # Disables the deal property history models
Expand Down
3 changes: 2 additions & 1 deletion dbt_project.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: 'hubspot'
version: '0.15.1'
version: '0.16.0'

config-version: 2
require-dbt-version: [">=1.3.0", "<2.0.0"]
Expand All @@ -13,6 +13,7 @@ vars:
company: "{{ ref('stg_hubspot__company') }}"
company_property_history: "{{ ref('stg_hubspot__company_property_history') }}"
deal: "{{ ref('stg_hubspot__deal') }}"
merged_deal: "{{ ref('stg_hubspot__merged_deal') }}"
deal_stage: "{{ ref('stg_hubspot__deal_stage') }}"
deal_company: "{{ ref('stg_hubspot__deal_company') }}"
deal_pipeline: "{{ ref('stg_hubspot__deal_pipeline') }}"
Expand Down
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_8
schema: hubspot_integration_tests_11
threads: 8
bigquery:
type: bigquery
method: service-account-json
project: 'dbt-package-testing'
schema: hubspot_integration_tests_8
schema: hubspot_integration_tests_11
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_8
schema: hubspot_integration_tests_11
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_8
schema: hubspot_integration_tests_11
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_8
schema: hubspot_integration_tests_11
threads: 8
token: "{{ env_var('CI_DATABRICKS_DBT_TOKEN') }}"
type: databricks
10 changes: 8 additions & 2 deletions integration_tests/dbt_project.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
name: 'hubspot_integration_tests'
version: '0.15.1'
version: '0.16.0'

profile: 'integration_tests'
config-version: 2
vars:
hubspot_schema: hubspot_integration_tests_8
hubspot_schema: hubspot_integration_tests_11
hubspot_source:
hubspot_service_enabled: true
# hubspot_sales_enabled: true # enable when generating docs
# hubspot_marketing_enabled: true # enable when generating docs
# hubspot_contact_merge_audit_enabled: true # enable when generating docs
# hubspot_using_all_email_events: true # enable when generating docs
# hubspot_merged_deal_enabled: true # enable when generating docs
hubspot_company_property_history_identifier: "company_property_history_data"
hubspot_company_identifier: "company_data"
hubspot_contact_identifier: "contact_data"
Expand Down Expand Up @@ -58,6 +59,7 @@ vars:
hubspot_contact_list_identifier: "contact_list_data"
hubspot_email_event_sent_identifier: "email_event_sent_data"
hubspot_email_event_dropped_identifier: "email_event_dropped_data"
hubspot_merged_deal_identifier: "merged_deal_data"

seeds:
hubspot_integration_tests:
Expand Down Expand Up @@ -173,6 +175,10 @@ seeds:
ticket_property_history_data:
+column_types:
timestamp_instant: timestamp
merged_deal_data:
+column_types:
deal_id: "{{ 'int64' if target.type == 'bigquery' else 'bigint' }}"
merged_deal_id: "{{ 'int64' if target.type == 'bigquery' else 'bigint' }}"

dispatch:
- macro_namespace: dbt_utils
Expand Down
15 changes: 15 additions & 0 deletions integration_tests/seeds/merged_deal_data.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
deal_id,merged_deal_id,_fivetran_synced
9089908390,9014070905,2023-06-22 11:37:07.210000
9089908390,9077310858,2023-06-22 11:37:07.210000
9089908390,9077311778,2023-06-22 11:37:07.210000
9089908390,9014071335,2023-06-22 11:37:07.210000
1364146343,10829010820,2023-06-22 11:37:07.220000
1364146343,10828874842,2023-06-22 11:37:07.220000
1368273549,10829051678,2023-06-22 11:37:07.227000
1368273549,10829028256,2023-06-22 11:37:07.227000
1373595330,10879517198,2023-06-22 11:37:07.227000
1373595330,10828874855,2023-06-22 11:37:07.227000
1006463008,10064581040,2023-06-22 11:37:07.213000
1006463008,9351825260,2023-06-22 11:37:07.213000
1389291069,12351788138,2023-06-28 11:18:32.940000
1389291069,13817889862,2023-06-28 11:18:32.939000
10 changes: 10 additions & 0 deletions macros/email_events_joined.sql
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ with base as (
select *
from {{ var('email_event') }}

{% if var('hubspot_contact_enabled', true) %}
), contacts as (

select *
from {{ ref('int_hubspot__contact_merge_adjust') }}
{% endif %}

), events_joined as (

Expand All @@ -28,6 +30,7 @@ with base as (
left join events
using (event_id)

{% if var('hubspot_contact_enabled', true) %}
), contacts_joined as (

select
Expand All @@ -43,4 +46,11 @@ with base as (
select *
from contacts_joined

{% else %}
)

select *
from events_joined

{% endif %}
{% endmacro %}
Loading
Loading