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

Feature/add union data #123

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
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: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# dbt_hubspot_source v0.15.0
fivetran-jamie marked this conversation as resolved.
Show resolved Hide resolved

Unioning coming soon...

# dbt_hubspot_source v0.14.0
[PR #122](https://github.com/fivetran/dbt_hubspot_source/pull/122) includes the following updates:

Expand Down
1,301 changes: 1,300 additions & 1 deletion README.md

Large diffs are not rendered by default.

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_source'
version: '0.14.0'
version: '0.15.0'
config-version: 2
require-dbt-version: [">=1.3.0", "<2.0.0"]
models:
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_source_integration_tests_999
schema: hubspot_source_integration_tests_001
threads: 8
bigquery:
type: bigquery
method: service-account-json
project: 'dbt-package-testing'
schema: hubspot_source_integration_tests_999
schema: hubspot_source_integration_tests_001
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_source_integration_tests_999
schema: hubspot_source_integration_tests_001
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_source_integration_tests_999
schema: hubspot_source_integration_tests_001
threads: 8
databricks:
catalog: null
host: "{{ env_var('CI_DATABRICKS_DBT_HOST') }}"
http_path: "{{ env_var('CI_DATABRICKS_DBT_HTTP_PATH') }}"
schema: hubspot_source_integration_tests_999
schema: hubspot_source_integration_tests_001
threads: 8
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,12 +1,12 @@
name: 'hubspot_source_integration_tests'
version: '0.14.0'
version: '0.15.0'
profile: 'integration_tests'
config-version: 2
models:
hubspot_source:
+schema:
vars:
hubspot_schema: hubspot_source_integration_tests_999
hubspot_schema: hubspot_source_integration_tests_001
hubspot_source:
hubspot_service_enabled: true
# hubspot_sales_enabled: true # enable when generating docs
Expand Down
4 changes: 4 additions & 0 deletions models/docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
Timestamp of when Fivetran synced a record.
{% enddocs %}

{% docs source_relation %}
The schema or database this record came from if you are unioning multiple connectors together in this package. If you are running the package on a single connector, this will be its schema name.
{% enddocs %}

{% docs _fivetran_deleted %}
Boolean indicating whether a record has been deleted in Hubspot and/or inferred deleted in Hubspot by Fivetran; _fivetran_deleted and is_deleted fields are equivalent.
{% enddocs %}
Expand Down
19 changes: 18 additions & 1 deletion models/stg_hubspot__company.sql
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ with base as (
staging_columns=get_company_columns()
)
}}

{{
fivetran_utils.source_relation(
union_schema_variable='hubspot_union_schemas',
union_database_variable='hubspot_union_databases'
)
}}

from base

), fields as (
Expand All @@ -27,6 +35,14 @@ with base as (
staging_columns=get_company_columns()
)
}}

{{
fivetran_utils.source_relation(
union_schema_variable='hubspot_union_schemas',
union_database_variable='hubspot_union_databases'
)
}}

{% if all_passthrough_column_check('stg_hubspot__company_tmp',get_company_columns()) > 0 %}
-- just pass everything through if extra columns are present, but ensure required columns are present.
,{{
Expand All @@ -52,7 +68,8 @@ with base as (
city,
state,
country,
company_annual_revenue
company_annual_revenue,
source_relation

--The below macro adds the fields defined within your hubspot__ticket_pass_through_columns variable into the staging model
{{ fivetran_utils.fill_pass_through_columns('hubspot__company_pass_through_columns') }}
Expand Down
10 changes: 9 additions & 1 deletion models/stg_hubspot__company.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,16 @@ models:
description: '{{ doc("history_name") }}'
- name: new_value
description: '{{ doc("history_value") }}'
- name: source_relation
description: '{{ doc("source_relation") }}'

- name: stg_hubspot__company
description: Each record represents a company in Hubspot.
tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- company_id
- source_relation
columns:
- name: _fivetran_synced
description: '{{ doc("_fivetran_synced") }}'
Expand All @@ -30,7 +37,6 @@ models:
- name: company_id
description: The ID of the company.
tests:
- unique
- not_null
- name: company_name
description: The name of the company.
Expand All @@ -52,3 +58,5 @@ models:
description: The country where the company is located.
- name: company_annual_revenue
description: The actual or estimated annual revenue of the company.
- name: source_relation
description: '{{ doc("source_relation") }}'
11 changes: 10 additions & 1 deletion models/stg_hubspot__company_property_history.sql
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ with base as (
staging_columns=get_company_property_history_columns()
)
}}

{{
fivetran_utils.source_relation(
union_schema_variable='hubspot_union_schemas',
union_database_variable='hubspot_union_databases'
)
}}

from base

), fields as (
Expand All @@ -25,7 +33,8 @@ with base as (
source as change_source,
source_id as change_source_id,
cast(change_timestamp as {{ dbt.type_timestamp() }}) as change_timestamp, -- source field name = timestamp ; alias declared in macros/get_company_property_history_columns.sql
value as new_value
value as new_value,
source_relation
from macro

)
Expand Down
19 changes: 18 additions & 1 deletion models/stg_hubspot__contact.sql
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ with base as (
staging_columns=get_contact_columns()
)
}}

{{
fivetran_utils.source_relation(
union_schema_variable='hubspot_union_schemas',
union_database_variable='hubspot_union_databases'
)
}}

from base

), fields as (
Expand All @@ -27,6 +35,14 @@ with base as (
staging_columns=get_contact_columns()
)
}}

{{
fivetran_utils.source_relation(
union_schema_variable='hubspot_union_schemas',
union_database_variable='hubspot_union_databases'
)
}}

{% if all_passthrough_column_check('stg_hubspot__contact_tmp',get_contact_columns()) > 0 %}
-- just pass everything through if extra columns are present, but ensure required columns are present.
,{{
Expand All @@ -50,7 +66,8 @@ with base as (
cast(created_date as {{ dbt.type_timestamp() }}) as created_date,
job_title,
company_annual_revenue,
cast(_fivetran_synced as {{ dbt.type_timestamp() }}) as _fivetran_synced
cast(_fivetran_synced as {{ dbt.type_timestamp() }}) as _fivetran_synced,
source_relation

--The below macro adds the fields defined within your hubspot__contact_pass_through_columns variable into the staging model
{{ fivetran_utils.fill_pass_through_columns('hubspot__contact_pass_through_columns') }}
Expand Down
24 changes: 21 additions & 3 deletions models/stg_hubspot__contact.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,16 @@ models:
description: The ID of the related contact.
- name: contact_list_id
description: The ID of the related contact list.
- name: source_relation
description: '{{ doc("source_relation") }}'

- name: stg_hubspot__contact_list
description: Each record represents a contact list in Hubspot.
tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- contact_list_id
- source_relation
columns:
- name: is_contact_list_deleted
description: '{{ doc("is_deleted") }}'
Expand All @@ -25,7 +32,6 @@ models:
- name: contact_list_id
description: The ID of the contact list.
tests:
- unique
- not_null
- name: contact_list_name
description: The name of the contact list.
Expand All @@ -51,6 +57,8 @@ models:
description: '{{ doc("portal_id") }}'
- name: updated_timestamp
description: A timestamp of the time that the list was last modified.
- name: source_relation
description: '{{ doc("source_relation") }}'

- name: stg_hubspot__contact_property_history
description: Each record represents a change to contact record in Hubspot.
Expand All @@ -69,6 +77,8 @@ models:
description: '{{ doc("history_name") }}'
- name: new_value
description: '{{ doc("history_value") }}'
- name: source_relation
description: '{{ doc("source_relation") }}'

- name: stg_hubspot__contact_merge_audit
description: Each record contains a contact merge event and the contacts effected by the merge.
Expand All @@ -93,9 +103,16 @@ models:
description: The ID of the user.
- name: vid_to_merge
description: The ID of the contact which was merged.
- name: source_relation
description: '{{ doc("source_relation") }}'

- name: stg_hubspot__contact
description: Each record represents a contact in Hubspot.
tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- contact_id
- source_relation
columns:
- name: is_contact_deleted
description: '{{ doc("is_deleted") }}'
Expand All @@ -104,7 +121,6 @@ models:
- name: contact_id
description: The ID of the contact.
tests:
- unique
- not_null
- name: email
description: The email address of the contact.
Expand All @@ -126,4 +142,6 @@ models:
description: >
List of mappings representing contact IDs that have been merged into the contact at hand.
Format: <merged_contact_id>:<merged_at_in_epoch_time>;<second_merged_contact_id>:<merged_at_in_epoch_time>
This field has replaced the `CONTACT_MERGE_AUDIT` table, which was deprecated by the Hubspot v3 CRM API.
This field has replaced the `CONTACT_MERGE_AUDIT` table, which was deprecated by the Hubspot v3 CRM API.
- name: source_relation
description: '{{ doc("source_relation") }}'
11 changes: 10 additions & 1 deletion models/stg_hubspot__contact_list.sql
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ with base as (
staging_columns=get_contact_list_columns()
)
}}

{{
fivetran_utils.source_relation(
union_schema_variable='hubspot_union_schemas',
union_database_variable='hubspot_union_databases'
)
}}

from base

), fields as (
Expand All @@ -32,7 +40,8 @@ with base as (
metadata_size,
name as contact_list_name,
portal_id,
cast(updated_at as {{ dbt.type_timestamp() }}) as updated_timestamp
cast(updated_at as {{ dbt.type_timestamp() }}) as updated_timestamp,
source_relation
from macro

)
Expand Down
11 changes: 10 additions & 1 deletion models/stg_hubspot__contact_list_member.sql
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ with base as (
staging_columns=get_contact_list_member_columns()
)
}}

{{
fivetran_utils.source_relation(
union_schema_variable='hubspot_union_schemas',
union_database_variable='hubspot_union_databases'
)
}}

from base

), fields as (
Expand All @@ -23,7 +31,8 @@ with base as (
cast(_fivetran_synced as {{ dbt.type_timestamp() }}) as _fivetran_synced,
cast(added_at as {{ dbt.type_timestamp() }}) as added_timestamp,
contact_id,
contact_list_id
contact_list_id,
source_relation
from macro

)
Expand Down
11 changes: 10 additions & 1 deletion models/stg_hubspot__contact_merge_audit.sql
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ with base as (
staging_columns=get_contact_merge_audit_columns()
)
}}

{{
fivetran_utils.source_relation(
union_schema_variable='hubspot_union_schemas',
union_database_variable='hubspot_union_databases'
)
}}

from base

), fields as (
Expand All @@ -33,7 +41,8 @@ with base as (
as {{ dbt.type_timestamp() }}) as timestamp_at,
user_id,
vid_to_merge,
cast(_fivetran_synced as {{ dbt.type_timestamp() }}) as _fivetran_synced
cast(_fivetran_synced as {{ dbt.type_timestamp() }}) as _fivetran_synced,
source_relation
from macro

)
Expand Down
12 changes: 11 additions & 1 deletion models/stg_hubspot__contact_property_history.sql
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ with base as (
staging_columns=get_contact_property_history_columns()
)
}}

{{
fivetran_utils.source_relation(
union_schema_variable='hubspot_union_schemas',
union_database_variable='hubspot_union_databases'
)
}}

from base

), fields as (
Expand All @@ -25,7 +33,9 @@ with base as (
source as change_source,
source_id as change_source_id,
cast(change_timestamp as {{ dbt.type_timestamp() }}) as change_timestamp, -- source field name = timestamp ; alias declared in macros/get_contact_property_history_columns.sql
value as new_value
value as new_value,
source_relation

from macro

)
Expand Down
Loading