Skip to content

Commit

Permalink
Merge pull request #6 from fivetran/feature/best-practice
Browse files Browse the repository at this point in the history
Best Practices
  • Loading branch information
fivetran-jamie authored Mar 30, 2021
2 parents 578458b + 70624c2 commit 4801002
Show file tree
Hide file tree
Showing 44 changed files with 1,242 additions and 42 deletions.
23 changes: 23 additions & 0 deletions macros/get_activity_change_data_value_columns.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{% macro get_activity_change_data_value_columns() %}

{% set columns = [
{"name": "_fivetran_synced", "datatype": dbt_utils.type_timestamp()},
{"name": "activity_date", "datatype": dbt_utils.type_timestamp()},
{"name": "activity_type_id", "datatype": dbt_utils.type_int()},
{"name": "api_method_name", "datatype": dbt_utils.type_string()},
{"name": "campaign_id", "datatype": dbt_utils.type_int()},
{"name": "id", "datatype": dbt_utils.type_string()},
{"name": "lead_id", "datatype": dbt_utils.type_int()},
{"name": "modifying_user", "datatype": dbt_utils.type_string()},
{"name": "new_value", "datatype": dbt_utils.type_string()},
{"name": "old_value", "datatype": dbt_utils.type_string()},
{"name": "primary_attribute_value", "datatype": dbt_utils.type_string()},
{"name": "primary_attribute_value_id", "datatype": dbt_utils.type_int()},
{"name": "reason", "datatype": dbt_utils.type_string()},
{"name": "request_id", "datatype": dbt_utils.type_string()},
{"name": "source", "datatype": dbt_utils.type_string()}
] %}

{{ return(columns) }}

{% endmacro %}
27 changes: 27 additions & 0 deletions macros/get_activity_click_email_columns.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{% macro get_activity_click_email_columns() %}

{% set columns = [
{"name": "_fivetran_synced", "datatype": dbt_utils.type_timestamp()},
{"name": "activity_date", "datatype": dbt_utils.type_timestamp()},
{"name": "activity_type_id", "datatype": dbt_utils.type_int()},
{"name": "campaign_id", "datatype": dbt_utils.type_int()},
{"name": "campaign_run_id", "datatype": dbt_utils.type_int()},
{"name": "choice_number", "datatype": dbt_utils.type_int()},
{"name": "device", "datatype": dbt_utils.type_string()},
{"name": "email_template_id", "datatype": dbt_utils.type_int()},
{"name": "id", "datatype": dbt_utils.type_string()},
{"name": "is_mobile_device", "datatype": "boolean"},
{"name": "lead_id", "datatype": dbt_utils.type_int()},
{"name": "link", "datatype": dbt_utils.type_string()},
{"name": "link_id", "datatype": dbt_utils.type_string()},
{"name": "platform", "datatype": dbt_utils.type_string()},
{"name": "primary_attribute_value", "datatype": dbt_utils.type_string()},
{"name": "primary_attribute_value_id", "datatype": dbt_utils.type_int()},
{"name": "step_id", "datatype": dbt_utils.type_int()},
{"name": "test_variant", "datatype": dbt_utils.type_int()},
{"name": "user_agent", "datatype": dbt_utils.type_string()}
] %}

{{ return(columns) }}

{% endmacro %}
17 changes: 17 additions & 0 deletions macros/get_activity_delete_lead_columns.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{% macro get_activity_delete_lead_columns() %}

{% set columns = [
{"name": "_fivetran_synced", "datatype": dbt_utils.type_timestamp()},
{"name": "activity_date", "datatype": dbt_utils.type_timestamp()},
{"name": "activity_type_id", "datatype": dbt_utils.type_int()},
{"name": "campaign", "datatype": dbt_utils.type_string()},
{"name": "campaign_id", "datatype": dbt_utils.type_int()},
{"name": "id", "datatype": dbt_utils.type_string()},
{"name": "lead_id", "datatype": dbt_utils.type_int()},
{"name": "primary_attribute_value", "datatype": dbt_utils.type_string()},
{"name": "primary_attribute_value_id", "datatype": dbt_utils.type_int()}
] %}

{{ return(columns) }}

{% endmacro %}
25 changes: 25 additions & 0 deletions macros/get_activity_email_bounced_columns.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{% macro get_activity_email_bounced_columns() %}

{% set columns = [
{"name": "_fivetran_synced", "datatype": dbt_utils.type_timestamp()},
{"name": "activity_date", "datatype": dbt_utils.type_timestamp()},
{"name": "activity_type_id", "datatype": dbt_utils.type_int()},
{"name": "campaign_id", "datatype": dbt_utils.type_int()},
{"name": "campaign_run_id", "datatype": dbt_utils.type_int()},
{"name": "category", "datatype": dbt_utils.type_int()},
{"name": "choice_number", "datatype": dbt_utils.type_int()},
{"name": "details", "datatype": dbt_utils.type_string()},
{"name": "email", "datatype": dbt_utils.type_string()},
{"name": "email_template_id", "datatype": dbt_utils.type_int()},
{"name": "id", "datatype": dbt_utils.type_string()},
{"name": "lead_id", "datatype": dbt_utils.type_int()},
{"name": "primary_attribute_value", "datatype": dbt_utils.type_string()},
{"name": "primary_attribute_value_id", "datatype": dbt_utils.type_int()},
{"name": "step_id", "datatype": dbt_utils.type_int()},
{"name": "subcategory", "datatype": dbt_utils.type_int()},
{"name": "test_variant", "datatype": dbt_utils.type_int()}
] %}

{{ return(columns) }}

{% endmacro %}
21 changes: 21 additions & 0 deletions macros/get_activity_email_delivered_columns.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{% macro get_activity_email_delivered_columns() %}

{% set columns = [
{"name": "_fivetran_synced", "datatype": dbt_utils.type_timestamp()},
{"name": "activity_date", "datatype": dbt_utils.type_timestamp()},
{"name": "activity_type_id", "datatype": dbt_utils.type_int()},
{"name": "campaign_id", "datatype": dbt_utils.type_int()},
{"name": "campaign_run_id", "datatype": dbt_utils.type_int()},
{"name": "choice_number", "datatype": dbt_utils.type_int()},
{"name": "email_template_id", "datatype": dbt_utils.type_int()},
{"name": "id", "datatype": dbt_utils.type_string()},
{"name": "lead_id", "datatype": dbt_utils.type_int()},
{"name": "primary_attribute_value", "datatype": dbt_utils.type_string()},
{"name": "primary_attribute_value_id", "datatype": dbt_utils.type_int()},
{"name": "step_id", "datatype": dbt_utils.type_int()},
{"name": "test_variant", "datatype": dbt_utils.type_int()}
] %}

{{ return(columns) }}

{% endmacro %}
20 changes: 20 additions & 0 deletions macros/get_activity_merge_leads_columns.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{% macro get_activity_merge_leads_columns() %}

{% set columns = [
{"name": "_fivetran_synced", "datatype": dbt_utils.type_timestamp()},
{"name": "activity_date", "datatype": dbt_utils.type_timestamp()},
{"name": "activity_type_id", "datatype": dbt_utils.type_int()},
{"name": "campaign_id", "datatype": dbt_utils.type_int()},
{"name": "id", "datatype": dbt_utils.type_string()},
{"name": "lead_id", "datatype": dbt_utils.type_int()},
{"name": "master_updated", "datatype": "boolean"},
{"name": "merge_ids", "datatype": dbt_utils.type_string()},
{"name": "merge_source", "datatype": dbt_utils.type_string()},
{"name": "merged_in_sales", "datatype": "boolean"},
{"name": "primary_attribute_value", "datatype": dbt_utils.type_string()},
{"name": "primary_attribute_value_id", "datatype": dbt_utils.type_int()}
] %}

{{ return(columns) }}

{% endmacro %}
25 changes: 25 additions & 0 deletions macros/get_activity_open_email_columns.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{% macro get_activity_open_email_columns() %}

{% set columns = [
{"name": "_fivetran_synced", "datatype": dbt_utils.type_timestamp()},
{"name": "activity_date", "datatype": dbt_utils.type_timestamp()},
{"name": "activity_type_id", "datatype": dbt_utils.type_int()},
{"name": "campaign_id", "datatype": dbt_utils.type_int()},
{"name": "campaign_run_id", "datatype": dbt_utils.type_int()},
{"name": "choice_number", "datatype": dbt_utils.type_int()},
{"name": "device", "datatype": dbt_utils.type_string()},
{"name": "email_template_id", "datatype": dbt_utils.type_int()},
{"name": "id", "datatype": dbt_utils.type_string()},
{"name": "is_mobile_device", "datatype": "boolean"},
{"name": "lead_id", "datatype": dbt_utils.type_int()},
{"name": "platform", "datatype": dbt_utils.type_string()},
{"name": "primary_attribute_value", "datatype": dbt_utils.type_string()},
{"name": "primary_attribute_value_id", "datatype": dbt_utils.type_int()},
{"name": "step_id", "datatype": dbt_utils.type_int()},
{"name": "test_variant", "datatype": dbt_utils.type_int()},
{"name": "user_agent", "datatype": dbt_utils.type_string()}
] %}

{{ return(columns) }}

{% endmacro %}
21 changes: 21 additions & 0 deletions macros/get_activity_send_email_columns.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{% macro get_activity_send_email_columns() %}

{% set columns = [
{"name": "_fivetran_synced", "datatype": dbt_utils.type_timestamp()},
{"name": "activity_date", "datatype": dbt_utils.type_timestamp()},
{"name": "activity_type_id", "datatype": dbt_utils.type_int()},
{"name": "campaign_id", "datatype": dbt_utils.type_int()},
{"name": "campaign_run_id", "datatype": dbt_utils.type_int()},
{"name": "choice_number", "datatype": dbt_utils.type_int()},
{"name": "email_template_id", "datatype": dbt_utils.type_int()},
{"name": "id", "datatype": dbt_utils.type_string()},
{"name": "lead_id", "datatype": dbt_utils.type_int()},
{"name": "primary_attribute_value", "datatype": dbt_utils.type_string()},
{"name": "primary_attribute_value_id", "datatype": dbt_utils.type_int()},
{"name": "step_id", "datatype": dbt_utils.type_int()},
{"name": "test_variant", "datatype": dbt_utils.type_int()}
] %}

{{ return(columns) }}

{% endmacro %}
26 changes: 26 additions & 0 deletions macros/get_activity_unsubscribe_email_columns.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{% macro get_activity_unsubscribe_email_columns() %}

{% set columns = [
{"name": "_fivetran_synced", "datatype": dbt_utils.type_timestamp()},
{"name": "activity_date", "datatype": dbt_utils.type_timestamp()},
{"name": "activity_type_id", "datatype": dbt_utils.type_int()},
{"name": "campaign_id", "datatype": dbt_utils.type_int()},
{"name": "campaign_run_id", "datatype": dbt_utils.type_int()},
{"name": "client_ip_address", "datatype": dbt_utils.type_string()},
{"name": "email_template_id", "datatype": dbt_utils.type_int()},
{"name": "form_fields", "datatype": dbt_utils.type_string()},
{"name": "id", "datatype": dbt_utils.type_string()},
{"name": "lead_id", "datatype": dbt_utils.type_int()},
{"name": "primary_attribute_value", "datatype": dbt_utils.type_string()},
{"name": "primary_attribute_value_id", "datatype": dbt_utils.type_int()},
{"name": "query_parameters", "datatype": dbt_utils.type_string()},
{"name": "referrer_url", "datatype": dbt_utils.type_string()},
{"name": "test_variant", "datatype": dbt_utils.type_int()},
{"name": "user_agent", "datatype": dbt_utils.type_string()},
{"name": "webform_id", "datatype": dbt_utils.type_int()},
{"name": "webpage_id", "datatype": dbt_utils.type_int()}
] %}

{{ return(columns) }}

{% endmacro %}
19 changes: 19 additions & 0 deletions macros/get_campaign_columns.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{% macro get_campaign_columns() %}

{% set columns = [
{"name": "_fivetran_synced", "datatype": dbt_utils.type_timestamp()},
{"name": "active", "datatype": "boolean"},
{"name": "created_at", "datatype": dbt_utils.type_timestamp()},
{"name": "description", "datatype": dbt_utils.type_string()},
{"name": "id", "datatype": dbt_utils.type_int()},
{"name": "name", "datatype": dbt_utils.type_string()},
{"name": "program_id", "datatype": dbt_utils.type_int()},
{"name": "program_name", "datatype": dbt_utils.type_string()},
{"name": "type", "datatype": dbt_utils.type_string()},
{"name": "updated_at", "datatype": dbt_utils.type_timestamp()},
{"name": "workspace_name", "datatype": dbt_utils.type_string()}
] %}

{{ return(columns) }}

{% endmacro %}
32 changes: 32 additions & 0 deletions macros/get_email_template_history_columns.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{% macro get_email_template_history_columns() %}

{% set columns = [
{"name": "_fivetran_synced", "datatype": dbt_utils.type_timestamp()},
{"name": "created_at", "datatype": dbt_utils.type_timestamp()},
{"name": "description", "datatype": dbt_utils.type_string()},
{"name": "folder_folder_name", "datatype": dbt_utils.type_string()},
{"name": "folder_id", "datatype": dbt_utils.type_int()},
{"name": "folder_type", "datatype": dbt_utils.type_string()},
{"name": "folder_value", "datatype": dbt_utils.type_int()},
{"name": "from_email", "datatype": dbt_utils.type_string()},
{"name": "from_name", "datatype": dbt_utils.type_string()},
{"name": "id", "datatype": dbt_utils.type_int()},
{"name": "name", "datatype": dbt_utils.type_string()},
{"name": "operational", "datatype": "boolean"},
{"name": "program_id", "datatype": dbt_utils.type_int()},
{"name": "publish_to_msi", "datatype": "boolean"},
{"name": "reply_email", "datatype": dbt_utils.type_string()},
{"name": "status", "datatype": dbt_utils.type_string()},
{"name": "subject", "datatype": dbt_utils.type_string()},
{"name": "template", "datatype": dbt_utils.type_int()},
{"name": "text_only", "datatype": "boolean"},
{"name": "updated_at", "datatype": dbt_utils.type_timestamp()},
{"name": "url", "datatype": dbt_utils.type_string()},
{"name": "version", "datatype": dbt_utils.type_int()},
{"name": "web_view", "datatype": "boolean"},
{"name": "workspace", "datatype": dbt_utils.type_string()}
] %}

{{ return(columns) }}

{% endmacro %}
Loading

0 comments on commit 4801002

Please sign in to comment.