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
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
# 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.

## 🚨 Breaking Changes 🚨
- The `hubspot__deal_stages` model has undergone two major changes:
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`.

# dbt_hubspot v0.5.4
## Fixes
- Typo fix and spelling correction within the README. ([#70](https://github.com/fivetran/dbt_hubspot/pull/70))
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: 'hubspot'
version: '0.5.4'
version: '0.6.0'
config-version: 2
require-dbt-version: [">=1.0.0", "<2.0.0"]

Expand Down
2 changes: 1 addition & 1 deletion integration_tests/dbt_project.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

name: 'hubspot_integration_tests'
version: '0.5.4'
version: '0.6.0'
profile: 'integration_tests'
config-version: 2

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: 6 additions & 2 deletions packages.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
packages:
- package: fivetran/hubspot_source
version: [">=0.5.0", "<0.6.0"]
# - package: fivetran/hubspot_source
# version: [">=0.5.0", "<0.6.0"]
- git: https://github.com/fivetran/dbt_hubspot_source.git
revision: feature/disable-ticket-deal
warn-unpinned: false
# - local: ../Hubspot/dbt_hubspot_source
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 switch before merge.