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

hubspot__deal_stages should reflect info about every stage #78

Merged
merged 12 commits into from
Aug 24, 2022
20 changes: 18 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,23 @@
# dbt_hubspot v0.6.0
## 🎉 Documentation and Feature Updates
- Updated README documentation updates for easier navigation and setup of the dbt package
- Included `hubspot_[source_table_name]_identifier` variable for additional flexibility within the package when source tables are named differently.
- Updated README documentation updates for easier navigation and setup of the dbt package ([#67](https://github.com/fivetran/dbt_hubspot/pull/67)).
- Included `hubspot_[source_table_name]_identifier` variable for additional flexibility within the package when source tables are named differently ([#67](https://github.com/fivetran/dbt_hubspot/pull/67)).
- Adds `hubspot_ticket_deal_enabled` variable (default value=`False`) to disable modelling and testing of the `ticket_deal` source table. If there are no associations between tickets and deals in your Hubspot environment, this table will not exist ([#79](https://github.com/fivetran/dbt_hubspot_source/pull/79)).

## 🚨 Breaking Changes 🚨
- The `hubspot__deal_stages` model has undergone two major changes ([#78](https://github.com/fivetran/dbt_hubspot/pull/78)):
1. The stage and pipeline label columns now reflect where the deal was at a certain point of time (from `date_stage_entered` to `date_stage_exited`). Previously, this information reflected the deal's _current_ stage and pipeline in every record associated with the deal.
2. This model previously passed through _all_ fields from the parent deals model. We removed these fields, as they are all present in `hubspot__deals` final model and do not change across deal stages. If you would like to join `DEAL` fields into the `hubspot__deal_stages` model, join `hubspot__deal_stages` with `hubspot__deals` on `deal_id`.
- Consistently renames `property_dealname`, `property_closedate`, and `property_createdate` to `deal_name`, `closed_at`, and `created_at`, respectively, in the `deals` model. Previously, if `hubspot__pass_through_all_columns = true`, only the prefix `property_` was removed from the names of these fields, while they were completely renamed to `deal_name`, `closed_at`, and `created_at` if `hubspot__pass_through_all_columns = false` ([#79](https://github.com/fivetran/dbt_hubspot_source/pull/79)).

# dbt_hubspot v0.5.4
## Fixes
- Typo fix and spelling correction within the README. ([#70](https://github.com/fivetran/dbt_hubspot/pull/70))
- Spelling correction of the variable names within the README. ([#74](https://github.com/fivetran/dbt_hubspot/pull/74))

## Contributors
- [@moreaupascal56](https://github.com/moreaupascal56) ([#70](https://github.com/fivetran/dbt_hubspot/pull/70), [#74](https://github.com/fivetran/dbt_hubspot/pull/74))

# dbt_hubspot v0.5.3
## Under the Hood
- Added integration testing to support the new `stg_hubspot__deal_contact` model to the `dbt_hubspot_source` package.
Expand Down
33 changes: 31 additions & 2 deletions models/sales/hubspot__deal_stages.sql
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,47 @@ with deals_enhanced as (
select *
from {{ var('deal_stage') }}

), pipeline_stage as (

select *
from {{ var('deal_pipeline_stage') }}

), pipeline as (

select *
from {{ var('deal_pipeline') }}

), final as (

select
deal_stage.deal_id || '-' || row_number() over(partition by deal_stage.deal_id order by deal_stage.date_entered asc) as deal_stage_id,
deal_stage.deal_stage_name,
deals_enhanced.deal_id,
deals_enhanced.deal_name,
deal_stage._fivetran_start as date_stage_entered,
deal_stage._fivetran_end as date_stage_exited,
deal_stage._fivetran_active as is_stage_active,
deals_enhanced.*

deal_stage.deal_stage_name as pipeline_stage_id,
pipeline_stage.pipeline_stage_label,
pipeline_stage.deal_pipeline_id as pipeline_id,
pipeline.pipeline_label,
deal_stage.source,
deal_stage.source_id,
pipeline_stage.is_active as is_pipeline_stage_active,
pipeline.is_active as is_pipeline_active,
pipeline_stage.is_closed_won as is_pipeline_stage_closed_won,
pipeline_stage.display_order as pipeline_stage_display_order,
pipeline.display_order as pipeline_display_order,
pipeline_stage.probability as pipeline_stage_probability

from deal_stage

left join pipeline_stage
on deal_stage.deal_stage_name = pipeline_stage.deal_pipeline_stage_id

left join pipeline
on pipeline_stage.deal_pipeline_id = pipeline.deal_pipeline_id

left join deals_enhanced
on deal_stage.deal_id = deals_enhanced.deal_id
)
Expand Down
39 changes: 24 additions & 15 deletions models/sales/sales.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ models:
- not_null
- unique

- name: deal_stage_name
- name: pipeline_stage_id
description: The name of the deal stage.

- name: date_stage_entered
Expand All @@ -78,37 +78,46 @@ models:
description: The Fivetran calculated exit time of the deal stage.

- name: is_stage_active
description: Boolean indicating whether the deal stage is active.
description: Boolean indicating whether the deal stage active.

- name: deal_id
description: The ID of the deal.

- name: deal_pipeline_id
- name: pipeline_id
description: The ID of the deal's pipeline.

- name: deal_pipeline_stage_id
- name: pipeline_stage_id
description: The ID of the deal's pipeline stage.

- name: owner_id
description: The ID of the deal's owner.

- name: portal_id
description: '{{ doc("portal_id") }}'

- name: pipeline_label
description: The label of the deal's pipeline.

- name: is_pipeline_active
description: Boolean indicating if the deal pipeline is active.
description: Boolean indicating if the pipeline is active.

- name: is_pipeline_stage_active
description: Boolean indicating if the pipeline stage is active.

- name: pipeline_stage_label
description: The label of the deal's pipeline stage.

- name: owner_email_address
description: The email address of the deal's owner.
- name: source
description: The relevant source of the deal stage.

- name: owner_full_name
description: The full name of the deal's owner.
- name: source_id
description: Reference to the source.

- name: is_pipeline_stage_closed_won
description: Whether the stage represents a Closed Won deal.

- name: pipeline_stage_display_order
description: Used to determine the order in which the stages appear when viewed in HubSpot.

- name: pipeline_stage_probability
description: The probability that the deal will close. Used for the deal forecast.

- name: deal_name
description: The name you have given this deal.

- name: hubspot__companies
description: Each record represents a company in Hubspot.
Expand Down
8 changes: 4 additions & 4 deletions packages.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
packages:
- git: https://github.com/fivetran/dbt_hubspot_source.git
revision: main
warn-unpinned: false
## TO SWITCH BEFORE MERGE
# - package: fivetran/hubspot_source
# version: [">=0.6.0", "<0.7.0"]
- git: https://github.com/fivetran/dbt_hubspot_source.git
revision: feature/package-updates
warn-unpinned: false
# version: [">=0.6.0", "<0.7.0"]