From 8cfa124f3611ccc96a861982592637f21a1e4455 Mon Sep 17 00:00:00 2001 From: Savage Fivetran Date: Mon, 22 Jun 2026 11:19:59 -0700 Subject: [PATCH 1/2] bugfix/cast_tag_and_company_id_as_string --- CHANGELOG.md | 16 ++++++++++++++++ README.md | 2 +- dbt_project.yml | 2 +- integration_tests/dbt_project.yml | 2 +- .../staging/get_company_tag_history_columns.sql | 2 +- .../staging/get_contact_tag_history_columns.sql | 2 +- .../get_conversation_tag_history_columns.sql | 2 +- macros/staging/get_tag_columns.sql | 2 +- models/staging/stg_intercom__company_history.sql | 2 +- .../stg_intercom__company_tag_history.sql | 4 ++-- .../stg_intercom__contact_company_history.sql | 2 +- .../stg_intercom__contact_tag_history.sql | 2 +- .../stg_intercom__conversation_tag_history.sql | 2 +- models/staging/stg_intercom__tag.sql | 2 +- 14 files changed, 30 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 93e1342..0a57c10 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,19 @@ +# dbt_intercom v1.7.0 + +[PR #85](https://github.com/fivetran/dbt_intercom/pull/85) includes the following updates: + +## Schema/Data Change +**2 total changes • 1 possible breaking change** + +| Data Model(s) | Change type | Old | New | Notes | +| ------------- | ----------- | --- | --- | ----- | +| **(Breaking)** `stg_intercom__tag`, `stg_intercom__company_tag_history`, `stg_intercom__contact_tag_history`, `stg_intercom__conversation_tag_history` | Changed field | `tag_id` integer | `tag_id` string | Casts `tag_id` as a string so joins succeed regardless of source type. | +| `stg_intercom__company_history`, `stg_intercom__company_tag_history`, `stg_intercom__contact_company_history` | Changed field | `company_id` source type | `company_id` string | Casts `company_id` as a string for consistent join keys. | + +## Bug Fix +- Resolves a `Database Error` in `intercom__company_enhanced` (and other tag-joined models) caused by mismatched `tag_id` data types. The fix casts all ID join keys to string in staging. See the Schema/Data Change table above. + + # dbt_intercom v1.6.1 [PR #82](https://github.com/fivetran/dbt_intercom/pull/82) includes the following updates: diff --git a/README.md b/README.md index 656c022..56ff669 100644 --- a/README.md +++ b/README.md @@ -68,7 +68,7 @@ Include the following intercom package version in your `packages.yml` file: ```yaml packages: - package: fivetran/intercom - version: [">=1.6.0", "<1.7.0"] + version: [">=1.7.0", "<1.8.0"] ``` ### Define database and schema variables diff --git a/dbt_project.yml b/dbt_project.yml index 8e6264f..85f68a3 100644 --- a/dbt_project.yml +++ b/dbt_project.yml @@ -1,6 +1,6 @@ config-version: 2 name: 'intercom' -version: '1.6.1' +version: '1.7.0' require-dbt-version: [">=1.3.0", "<3.0.0"] models: intercom: diff --git a/integration_tests/dbt_project.yml b/integration_tests/dbt_project.yml index 87c4ddf..8097482 100644 --- a/integration_tests/dbt_project.yml +++ b/integration_tests/dbt_project.yml @@ -1,5 +1,5 @@ name: 'intercom_integration_tests' -version: '1.6.1' +version: '1.7.0' profile: 'integration_tests' config-version: 2 diff --git a/macros/staging/get_company_tag_history_columns.sql b/macros/staging/get_company_tag_history_columns.sql index 893129d..ed7d93a 100644 --- a/macros/staging/get_company_tag_history_columns.sql +++ b/macros/staging/get_company_tag_history_columns.sql @@ -7,7 +7,7 @@ {"name": "_fivetran_synced", "datatype": dbt.type_string()}, {"name": "company_id", "datatype": dbt.type_string()}, {"name": "company_updated_at", "datatype": dbt.type_timestamp()}, - {"name": "tag_id", "datatype": dbt.type_int()} + {"name": "tag_id", "datatype": dbt.type_string()} ] %} {{ return(columns) }} diff --git a/macros/staging/get_contact_tag_history_columns.sql b/macros/staging/get_contact_tag_history_columns.sql index 504b4b5..563338f 100644 --- a/macros/staging/get_contact_tag_history_columns.sql +++ b/macros/staging/get_contact_tag_history_columns.sql @@ -7,7 +7,7 @@ {"name": "_fivetran_end", "datatype": dbt.type_timestamp()}, {"name": "contact_id", "datatype": dbt.type_string()}, {"name": "contact_updated_at", "datatype": dbt.type_timestamp()}, - {"name": "tag_id", "datatype": dbt.type_int()} + {"name": "tag_id", "datatype": dbt.type_string()} ] %} {{ return(columns) }} diff --git a/macros/staging/get_conversation_tag_history_columns.sql b/macros/staging/get_conversation_tag_history_columns.sql index 10c7a3e..da0107b 100644 --- a/macros/staging/get_conversation_tag_history_columns.sql +++ b/macros/staging/get_conversation_tag_history_columns.sql @@ -6,7 +6,7 @@ {"name": "_fivetran_end", "datatype": dbt.type_timestamp()}, {"name": "conversation_id", "datatype": dbt.type_int()}, {"name": "conversation_updated_at", "datatype": dbt.type_timestamp()}, - {"name": "tag_id", "datatype": dbt.type_int()} + {"name": "tag_id", "datatype": dbt.type_string()} ] %} {{ return(columns) }} diff --git a/macros/staging/get_tag_columns.sql b/macros/staging/get_tag_columns.sql index a81b7b0..fccc1d1 100644 --- a/macros/staging/get_tag_columns.sql +++ b/macros/staging/get_tag_columns.sql @@ -3,7 +3,7 @@ {% set columns = [ {"name": "_fivetran_deleted", "datatype": "boolean"}, {"name": "_fivetran_synced", "datatype": dbt.type_timestamp()}, - {"name": "id", "datatype": dbt.type_int()}, + {"name": "id", "datatype": dbt.type_string()}, {"name": "name", "datatype": dbt.type_string()} ] %} diff --git a/models/staging/stg_intercom__company_history.sql b/models/staging/stg_intercom__company_history.sql index bcba89d..e6ca470 100644 --- a/models/staging/stg_intercom__company_history.sql +++ b/models/staging/stg_intercom__company_history.sql @@ -33,7 +33,7 @@ final as ( select source_relation, - id as company_id, + cast(id as {{ dbt.type_string() }}) as company_id, name as company_name, website, industry, diff --git a/models/staging/stg_intercom__company_tag_history.sql b/models/staging/stg_intercom__company_tag_history.sql index d6707e3..57982d0 100644 --- a/models/staging/stg_intercom__company_tag_history.sql +++ b/models/staging/stg_intercom__company_tag_history.sql @@ -31,9 +31,9 @@ final as ( select source_relation, - company_id, + cast(company_id as {{ dbt.type_string() }}) as company_id, cast(company_updated_at as {{ dbt.type_timestamp() }}) as company_updated_at, - tag_id, + cast(tag_id as {{ dbt.type_string() }}) as tag_id, _fivetran_active, cast(_fivetran_start as {{ dbt.type_timestamp() }}) as _fivetran_start, cast(_fivetran_end as {{ dbt.type_timestamp() }}) as _fivetran_end diff --git a/models/staging/stg_intercom__contact_company_history.sql b/models/staging/stg_intercom__contact_company_history.sql index 6f57ae2..f64a5a6 100644 --- a/models/staging/stg_intercom__contact_company_history.sql +++ b/models/staging/stg_intercom__contact_company_history.sql @@ -31,7 +31,7 @@ final as ( select source_relation, - company_id, + cast(company_id as {{ dbt.type_string() }}) as company_id, contact_id, cast(contact_updated_at as {{ dbt.type_timestamp() }}) as contact_updated_at, _fivetran_active, diff --git a/models/staging/stg_intercom__contact_tag_history.sql b/models/staging/stg_intercom__contact_tag_history.sql index f02f954..3bc9d68 100644 --- a/models/staging/stg_intercom__contact_tag_history.sql +++ b/models/staging/stg_intercom__contact_tag_history.sql @@ -34,7 +34,7 @@ final as ( source_relation, contact_id, cast(contact_updated_at as {{ dbt.type_timestamp() }}) as contact_updated_at, - tag_id, + cast(tag_id as {{ dbt.type_string() }}) as tag_id, _fivetran_active, cast(_fivetran_start as {{ dbt.type_timestamp() }}) as _fivetran_start, cast(_fivetran_end as {{ dbt.type_timestamp() }}) as _fivetran_end diff --git a/models/staging/stg_intercom__conversation_tag_history.sql b/models/staging/stg_intercom__conversation_tag_history.sql index bc9c05c..ef8ae26 100644 --- a/models/staging/stg_intercom__conversation_tag_history.sql +++ b/models/staging/stg_intercom__conversation_tag_history.sql @@ -33,7 +33,7 @@ final as ( select source_relation, conversation_id, - tag_id, + cast(tag_id as {{ dbt.type_string() }}) as tag_id, _fivetran_active, cast(_fivetran_start as {{ dbt.type_timestamp() }}) as _fivetran_start, cast(_fivetran_end as {{ dbt.type_timestamp() }}) as _fivetran_end diff --git a/models/staging/stg_intercom__tag.sql b/models/staging/stg_intercom__tag.sql index 5348031..1d8e760 100644 --- a/models/staging/stg_intercom__tag.sql +++ b/models/staging/stg_intercom__tag.sql @@ -29,7 +29,7 @@ final as ( select source_relation, - id as tag_id, + cast(id as {{ dbt.type_string() }}) as tag_id, trim(name) as name, _fivetran_deleted from fields From fd42a16717b47256c0dce8a062b10270b9738e7e Mon Sep 17 00:00:00 2001 From: Savage Fivetran Date: Mon, 22 Jun 2026 11:44:07 -0700 Subject: [PATCH 2/2] Revise CHANGELOG --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0a57c10..e6ddab5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,8 +7,8 @@ | Data Model(s) | Change type | Old | New | Notes | | ------------- | ----------- | --- | --- | ----- | -| **(Breaking)** `stg_intercom__tag`, `stg_intercom__company_tag_history`, `stg_intercom__contact_tag_history`, `stg_intercom__conversation_tag_history` | Changed field | `tag_id` integer | `tag_id` string | Casts `tag_id` as a string so joins succeed regardless of source type. | -| `stg_intercom__company_history`, `stg_intercom__company_tag_history`, `stg_intercom__contact_company_history` | Changed field | `company_id` source type | `company_id` string | Casts `company_id` as a string for consistent join keys. | +| **(Breaking)** `stg_intercom__tag`, `stg_intercom__company_tag_history`, `stg_intercom__contact_tag_history`, `stg_intercom__conversation_tag_history` | Changed data type | integer | string | Casts `tag_id` as a string so joins succeed regardless of source type. | +| `stg_intercom__company_history`, `stg_intercom__company_tag_history`, `stg_intercom__contact_company_history` | explicit data type cast | source data type | string | Casts `company_id` as a string for consistent join keys. | ## Bug Fix - Resolves a `Database Error` in `intercom__company_enhanced` (and other tag-joined models) caused by mismatched `tag_id` data types. The fix casts all ID join keys to string in staging. See the Schema/Data Change table above.