fivetran / dbt_iterable_source

Fivetran data source models for Iterable using dbt.
https://fivetran.github.io/dbt_iterable_source/
Apache License 2.0
2 stars 5 forks source link
dbt dbt-packages fivetran iterable

Iterable Source dbt Package (docs)

What does this dbt package do?

This package does not apply freshness tests.

How do I use the dbt package?

Step 1: Prerequisites

To use this dbt package, you must have the following:

Unsubscribe tables are no longer history tables

For connectors created past August 2023, the user_unsubscribed_channel_history and user_unsubscribed_message_type_history Iterable objects will no longer be history tables as part of schema changes following Iterable's API updates. The fields have also changed. There is no lift required, since we have checks in place that will automatically persist the respective fields depending on what exists in your schema (they will still be history tables if you are using the old schema).

Please be sure you are syncing them as either both history or non-history.

Step 2: Install the package

Include the following Iterable package version in your packages.yml file.

TIP: Check dbt Hub for the latest installation instructions or read the dbt docs for more information on installing packages.

packages:
  - package: fivetran/iterable_source
    version: [">=0.10.0", "<0.11.0"]

Step 3: Define database and schema variables

By default, this package runs using your destination and the iterable schema of your target database. If this is not where your Iterable data is (for example, if your Iterable schema is named iterable_fivetran), add the following configuration to your root dbt_project.yml file:

vars:
  iterable_database: your_database_name
  iterable_schema: your_schema_name 

Step 4: Enabling/Disabling Models

Your Iterable connector might not sync every table that this package expects. If your syncs exclude certain tables, it is either because you do not use that functionality in Iterable or have actively excluded some tables from your syncs. In order to enable or disable the relevant tables in the package, you will need to add the following variable(s) to your dbt_project.yml file.

By default, all variables are assumed to be true.

vars:
    iterable__using_campaign_label_history: false                    # default is true
    iterable__using_user_unsubscribed_message_type: false           # default is true
    iterable__using_campaign_suppression_list_history: false         # default is true   
    iterable__using_event_extension: false         # default is true   

(Optional) Step 5: Additional configurations

Passing Through Additional Fields

This package includes fields we judged were standard across Iterable users. However, the Fivetran connector allows for additional columns to be brought through in the event_extension and user_history objects. Therefore, if you wish to bring them through, leverage our passthrough column variables. For event_extension columns, ensure that iterable__using_event_extension is set to True, which is the default.

Notice: A dbt run --full-refresh is required each time these variables are edited.

These variables allow for the passthrough fields to be aliased (alias) and casted (transform_sql) if desired, but not required. Datatype casting is configured via a sql snippet within the transform_sql key. You may add the desired sql while omitting the as field_name at the end and your custom pass-though fields will be casted accordingly. Use the below format for declaring the respective pass-through variables:

# dbt_project.yml

vars:
  iterable_event_extension_pass_through_columns:
    - name: "event_extension_field"
      alias: "renamed_field"
      transform_sql: "cast(renamed_field as string)"
  iterable_user_history_pass_through_columns:
    - name: "user_attribute"
      alias: "renamed_user_attribute"
    - name: "user_attribute_2"

Changing the Build Schema

By default, this package will build the Iterable staging models within a schema titled ( + _stg_iterable) in your target database. If this is not where your would like you Iterable staging data to be written to, add the following configuration to your dbt_project.yml file:

models:
    iterable_source:
        +schema: my_new_schema_name # leave blank for just the target_schema

Change the source table references

If an individual source table has a different name than what the package expects, add the table name as it appears in your destination to the respective variable:

IMPORTANT: See this project's dbt_project.yml variable declarations to see the expected names.

vars:
    iterable_<default_source_table_name>_identifier: "your_table_name"

Deprecated CAMPAIGN_SUPRESSION_LIST_HISTORY table

The Iterable connector schema originally misspelled the CAMPAIGN_SUPPRESSION_LIST_HISTORY table as CAMPAIGN_SUPRESSION_LIST_HISTORY (note the singular P). As of August 2021, Fivetran has deprecated the misspelled table and will only continue syncing the correctly named CAMPAIGN_SUPPRESSION_LIST_HISTORY table.

By default, this package refers to the new table (CAMPAIGN_SUPPRESSION_LIST_HISTORY). To change this so that the package works with the old misspelled source table (we do not recommend this, however), add the following configuration to your dbt_project.yml file:

vars:
    iterable_campaign_suppression_list_history_identifier: "campaign_supression_list_history"

(Optional) Step 6: Orchestrate your models with Fivetran Transformations for dbt Core™

Expand for details
Fivetran offers the ability for you to orchestrate your dbt project through [Fivetran Transformations for dbt Core™](https://fivetran.com/docs/transformations/dbt). Learn how to set up your project for orchestration through Fivetran in our [Transformations for dbt Core setup guides](https://fivetran.com/docs/transformations/dbt#setupguide).

Does this package have dependencies?

This dbt package is dependent on the following dbt packages. These dependencies are installed by default within this package. For more information on the following packages, refer to the dbt hub site.

IMPORTANT: If you have any of these dependent packages in your own packages.yml file, we highly recommend that you remove them from your root packages.yml to avoid package version conflicts.

packages:
    - package: fivetran/fivetran_utils
      version: [">=0.4.0", "<0.5.0"]

    - package: dbt-labs/dbt_utils
      version: [">=1.0.0", "<2.0.0"]

How is this package maintained and can I contribute?

Package Maintenance

The Fivetran team maintaining this package only maintains the latest version of the package. We highly recommend you stay consistent with the latest version of the package and refer to the CHANGELOG and release notes for more information on changes across versions.

Contributions

A small team of analytics engineers at Fivetran develops these dbt packages. However, the packages are made better by community contributions.

We highly encourage and welcome contributions to this package. Check out this dbt Discourse article on the best workflow for contributing to a package.

Are there any resources available?