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/connector name update #132

Merged
merged 6 commits into from
Jul 25, 2024
Merged
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
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
# dbt_fivetran_log v1.9.0
[PR #132](https://github.com/fivetran/dbt_fivetran_log/pull/132) includes the following updates:

## 🚨 Schema Changes 🚨
- Following the [July 2024 Fivetran Platform connector update](https://fivetran.com/docs/logs/fivetran-platform/changelog#july2024), the `connector_name` field has been added to the `incremental_mar` source table. As a result, the following changes have been applied:
- A new tmp model `stg_fivetran_platform__incremental_mar_tmp` has been created. This is necessary to ensure column consistency in downstream `incremental_mar` models.
- The `get_incremental_mar_columns()` macro has been added to ensure all required columns are present in the `stg_fivetran_platform__incremental_mar` model.
- The `stg_fivetran_platform__incremental_mar` has been updated to reference both the aforementioned tmp model and macro to fill empty fields if any required field is not present in the source.
- The `connector_name` field in the `stg_fivetran_platform__incremental_mar` model is now defined by: `coalesce(connector_name, connector_id)`. This ensures the data model will use the appropriate field to define the `connector_name`.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Worth calling out the seed changes to incremental_mar for validating that the data comes through properly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure thing, added.

## Under the Hood
- Updated integration test seed data within `integration_tests/seeds/incremental_mar.csv` to ensure new code updates are working as expected.

# dbt_fivetran_log v1.8.0
[PR #130](https://github.com/fivetran/dbt_fivetran_log/pull/130) includes the following updates:

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ Include the following Fivetran Platform package version range in your `packages.
```yaml
packages:
- package: fivetran/fivetran_log
version: [">=1.8.0", "<1.9.0"]
version: [">=1.9.0", "<1.10.0"]
```

> Note that although the source connector is now "Fivetran Platform", the package retains the old name of "fivetran_log".
Expand Down
2 changes: 1 addition & 1 deletion dbt_project.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
config-version: 2
name: 'fivetran_log'
version: '1.8.0'
version: '1.9.0'
require-dbt-version: [">=1.3.0", "<2.0.0"]

models:
Expand Down
2 changes: 1 addition & 1 deletion docs/catalog.json

Large diffs are not rendered by default.

47 changes: 10 additions & 37 deletions docs/index.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/manifest.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/run_results.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion integration_tests/dbt_project.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: 'fivetran_log_integration_tests'
version: '1.8.0'
version: '1.9.0'

config-version: 2
profile: 'integration_tests'
Expand Down
22 changes: 11 additions & 11 deletions integration_tests/seeds/incremental_mar.csv
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
connector_id,destination_id,free_type,measured_date,schema_name,sync_type,table_name,updated_at,_fivetran_synced,incremental_rows
this_connector,ups_trampoline,PAID,2022-01-31 00:00:00,this_connector,UNKNOWN,my_table,2022-09-01 6:12:13,2022-11-09 20:09:26,46
this_connector,ups_trampoline,PAID,2022-02-22 00:00:00,that_connector,UNKNOWN,drop_table,2022-05-22 8:29:22,2022-11-07 20:10:24,1
this_connector,television_trace,PAID,2022-03-01 00:00:00,that_connector,UNKNOWN,drop_table,2022-03-01 21:52:24,2022-11-07 20:10:15,8
this_connector,television_trace,PAID,2022-03-04 00:00:00,that_connector,UNKNOWN,drop_table,2022-03-04 16:19:05,2022-11-07 20:10:16,1
this_connector,television_trace,PAID,2022-07-29 00:00:00,that_connector,UNKNOWN,drop_table,2022-07-29 23:05:17,2022-11-07 20:10:33,4
this_connector,television_trace,PAID,2022-05-14 00:00:00,that_connector,UNKNOWN,drop_table,2022-05-14 11:07:37,2022-11-07 20:10:24,1
this_connector,television_trace,PAID,2021-09-19 00:00:00,that_connector,UNKNOWN,drop_table,2021-09-19 12:11:38,2022-11-07 20:09:55,0
that_connector,television_trace,PAID,2022-06-08 00:00:00,that_connector,UNKNOWN,drop_table,2022-06-08 21:29:07,2022-11-07 20:10:25,2
that_connector,television_trace,PAID,2022-03-05 00:00:00,that_connector,UNKNOWN,drop_table,2022-03-05 10:55:00,2022-11-07 20:10:16,1
that_connector,television_trace,PAID,2022-07-01 00:00:00,that_connector,UNKNOWN,drop_table,2022-07-01 21:56:37,2022-11-07 20:10:30,1
connector_name,connector_id,destination_id,free_type,measured_date,schema_name,sync_type,table_name,updated_at,_fivetran_synced,incremental_rows
this_connector,,ups_trampoline,PAID,2022-01-31 00:00:00,this_connector,UNKNOWN,my_table,2022-09-01 6:12:13,2022-11-09 20:09:26,46
this_connector,,ups_trampoline,PAID,2022-02-22 00:00:00,that_connector,UNKNOWN,drop_table,2022-05-22 8:29:22,2022-11-07 20:10:24,1
,this_connector,television_trace,PAID,2022-03-01 00:00:00,that_connector,UNKNOWN,drop_table,2022-03-01 21:52:24,2022-11-07 20:10:15,8
this_connector,,television_trace,PAID,2022-03-04 00:00:00,that_connector,UNKNOWN,drop_table,2022-03-04 16:19:05,2022-11-07 20:10:16,1
this_connector,,television_trace,PAID,2022-07-29 00:00:00,that_connector,UNKNOWN,drop_table,2022-07-29 23:05:17,2022-11-07 20:10:33,4
this_connector,,television_trace,PAID,2022-05-14 00:00:00,that_connector,UNKNOWN,drop_table,2022-05-14 11:07:37,2022-11-07 20:10:24,1
this_connector,,television_trace,PAID,2021-09-19 00:00:00,that_connector,UNKNOWN,drop_table,2021-09-19 12:11:38,2022-11-07 20:09:55,0
this_connector,,television_trace,PAID,2022-06-08 00:00:00,that_connector,UNKNOWN,drop_table,2022-06-08 21:29:07,2022-11-07 20:10:25,2
,this_connector,television_trace,PAID,2022-03-05 00:00:00,that_connector,UNKNOWN,drop_table,2022-03-05 10:55:00,2022-11-07 20:10:16,1
this_connector,,television_trace,PAID,2022-07-01 00:00:00,that_connector,UNKNOWN,drop_table,2022-07-01 21:56:37,2022-11-07 20:10:30,1
19 changes: 19 additions & 0 deletions macros/get_incremental_mar_columns.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{% macro get_incremental_mar_columns() %}

{% set columns = [
{"name": "_fivetran_synced", "datatype": dbt.type_timestamp()},
{"name": "connector_id", "datatype": dbt.type_string()},
{"name": "connector_name", "datatype": dbt.type_string()},
{"name": "destination_id", "datatype": dbt.type_string()},
{"name": "free_type", "datatype": dbt.type_string()},
{"name": "measured_date", "datatype": dbt.type_timestamp()},
{"name": "schema_name", "datatype": dbt.type_string()},
{"name": "sync_type", "datatype": dbt.type_string()},
{"name": "table_name", "datatype": dbt.type_string()},
{"name": "incremental_rows", "datatype": dbt.type_int()},
{"name": "updated_at", "datatype": dbt.type_timestamp()}
] %}

{{ return(columns) }}

{% endmacro %}
4 changes: 3 additions & 1 deletion models/staging/src_fivetran_platform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ sources:
Each measurement is calculated cumulatively for the month and includes all types of mar (paid, free, etc.)
columns:
- name: connector_id
description: The *name* of the connector being measured. Note - this is erroneously named and will be fixed soon by Fivetran.
description: The *name* of the connector being measured. This may still be present in older Fivetran Platform connectors. However, all connectors setup after July 2024 will not have this field as it has been replaced with connector_name.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we still call out that it's misnamed so that people don't assume connector_id in the other tables mean the same thing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I think that would be a good callout to still mention. Just updated the documentation and regen'd the docs.

- name: connector_name
description: The name of the connector being measured.
- name: destination_id
description: Foreign key referencing the `destination` whose table is being measured.
- name: free_type
Expand Down
2 changes: 1 addition & 1 deletion models/staging/stg_fivetran_platform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ models:
Each measurement is calculated cumulatively for the month and includes all types of mar (paid, free, etc.)
columns:
- name: connector_name
description: The *name* of the connector being measured. Note - this is erroneously named and will be fixed soon by Fivetran.
description: The name of the connector being measured.
- name: destination_id
description: Foreign key referencing the `destination` whose table is being measured.
- name: free_type
Expand Down
19 changes: 15 additions & 4 deletions models/staging/stg_fivetran_platform__incremental_mar.sql
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@
with base as (

select *
from {{ var('incremental_mar') }}
from {{ ref('stg_fivetran_platform__incremental_mar_tmp') }}
),

fields as (
select
{{
fivetran_utils.fill_staging_columns(
source_columns=adapter.get_columns_in_relation(ref('stg_fivetran_platform__incremental_mar_tmp')),
staging_columns=get_incremental_mar_columns()
)
}}
from base
),

final as (

select
connector_id as connector_name,
coalesce(connector_name, connector_id) as connector_name,
destination_id,
free_type,
cast(measured_date as {{ dbt.type_timestamp() }}) as measured_date,
Expand All @@ -17,8 +28,8 @@ fields as (
updated_at,
_fivetran_synced,
incremental_rows
from base
from fields
)

select *
Copy link
Contributor

@fivetran-avinash fivetran-avinash Jul 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This query is still pulling from the result of the fill_staging_columns macro, so the coalesce operation is not being applied. You will want to update this part to:

select * 
from final

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great catch, it seems this wasn't an issue because the fill_staging_columns macro has the connector_name regardless and therefore wasn't erroring out. Thanks for catching this and just updated.

from fields
from final
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
select *
from {{ var('incremental_mar') }}