From 20658dcf70947869460f8ff5cd0e0b0df7ecaae8 Mon Sep 17 00:00:00 2001 From: fivetran-catfritz <111930712+fivetran-catfritz@users.noreply.github.com> Date: Fri, 28 Jun 2024 19:50:40 -0500 Subject: [PATCH 1/7] bug/renamed-columns --- macros/get_account_columns.sql | 25 ++++++++ macros/get_contact_columns.sql | 25 +++++++- macros/get_event_columns.sql | 24 ++++++- macros/get_lead_columns.sql | 31 ++++++++- macros/get_opportunity_columns.sql | 26 +++++++- macros/get_opportunity_line_item_columns.sql | 21 +++++- macros/get_order_columns.sql | 34 +++++++++- macros/get_product_2_columns.sql | 20 ++++++ macros/get_task_columns.sql | 24 ++++++- macros/get_user_columns.sql | 19 +++++- macros/get_user_role_columns.sql | 6 +- models/salesforce/stg_salesforce__account.sql | 50 +++++++-------- models/salesforce/stg_salesforce__contact.sql | 46 ++++++------- models/salesforce/stg_salesforce__event.sql | 44 ++++++------- models/salesforce/stg_salesforce__lead.sql | 58 ++++++++--------- .../stg_salesforce__opportunity.sql | 48 +++++++------- .../stg_salesforce__opportunity_line_item.sql | 38 +++++------ models/salesforce/stg_salesforce__order.sql | 64 +++++++++---------- .../salesforce/stg_salesforce__product_2.sql | 40 ++++++------ models/salesforce/stg_salesforce__task.sql | 44 ++++++------- models/salesforce/stg_salesforce__user.sql | 34 +++++----- .../salesforce/stg_salesforce__user_role.sql | 8 +-- 22 files changed, 483 insertions(+), 246 deletions(-) diff --git a/macros/get_account_columns.sql b/macros/get_account_columns.sql index a61bc0e..7ad93c5 100644 --- a/macros/get_account_columns.sql +++ b/macros/get_account_columns.sql @@ -5,36 +5,61 @@ {"name": "_fivetran_synced", "datatype": dbt.type_timestamp()}, {"name": "_fivetran_active", "datatype": "boolean"}, {"name": "account_number", "datatype": dbt.type_string()}, + {"name": "accountnumber", "datatype": dbt.type_string()}, {"name": "account_source", "datatype": dbt.type_string()}, + {"name": "accountsource", "datatype": dbt.type_string()}, {"name": "annual_revenue", "datatype": dbt.type_float()}, + {"name": "annualrevenue", "datatype": dbt.type_float()}, {"name": "billing_city", "datatype": dbt.type_string()}, + {"name": "billingcity", "datatype": dbt.type_string()}, {"name": "billing_country", "datatype": dbt.type_string()}, + {"name": "billingcountry", "datatype": dbt.type_string()}, {"name": "billing_postal_code", "datatype": dbt.type_string()}, + {"name": "billingpostalcode", "datatype": dbt.type_string()}, {"name": "billing_state", "datatype": dbt.type_string()}, + {"name": "billingstate", "datatype": dbt.type_string()}, {"name": "billing_state_code", "datatype": dbt.type_string()}, + {"name": "billingstatecode", "datatype": dbt.type_string()}, {"name": "billing_street", "datatype": dbt.type_string()}, + {"name": "billingstreet", "datatype": dbt.type_string()}, {"name": "description", "datatype": dbt.type_string()}, {"name": "id", "datatype": dbt.type_string()}, {"name": "industry", "datatype": dbt.type_string()}, {"name": "is_deleted", "datatype": "boolean"}, + {"name": "isdeleted", "datatype": "boolean"}, {"name": "last_activity_date", "datatype": dbt.type_timestamp()}, + {"name": "lastactivitydate", "datatype": dbt.type_timestamp()}, {"name": "last_referenced_date", "datatype": dbt.type_timestamp()}, + {"name": "lastreferenceddate", "datatype": dbt.type_timestamp()}, {"name": "last_viewed_date", "datatype": dbt.type_timestamp()}, + {"name": "lastvieweddate", "datatype": dbt.type_timestamp()}, {"name": "master_record_id", "datatype": dbt.type_string()}, + {"name": "masterrecordid", "datatype": dbt.type_string()}, {"name": "name", "datatype": dbt.type_string()}, {"name": "number_of_employees", "datatype": dbt.type_int()}, + {"name": "numberofemployees", "datatype": dbt.type_int()}, {"name": "owner_id", "datatype": dbt.type_string()}, + {"name": "ownerid", "datatype": dbt.type_string()}, {"name": "ownership", "datatype": dbt.type_string()}, {"name": "parent_id", "datatype": dbt.type_string()}, + {"name": "parentid", "datatype": dbt.type_string()}, {"name": "rating", "datatype": dbt.type_string()}, {"name": "record_type_id", "datatype": dbt.type_string()}, + {"name": "recordtypeid", "datatype": dbt.type_string()}, {"name": "shipping_city", "datatype": dbt.type_string()}, + {"name": "shippingcity", "datatype": dbt.type_string()}, {"name": "shipping_country", "datatype": dbt.type_string()}, + {"name": "shippingcountry", "datatype": dbt.type_string()}, {"name": "shipping_country_code", "datatype": dbt.type_string()}, + {"name": "shippingcountrycode", "datatype": dbt.type_string()}, {"name": "shipping_postal_code", "datatype": dbt.type_string()}, + {"name": "shippingpostalcode", "datatype": dbt.type_string()}, {"name": "shipping_state", "datatype": dbt.type_string()}, + {"name": "shippingstate", "datatype": dbt.type_string()}, {"name": "shipping_state_code", "datatype": dbt.type_string()}, + {"name": "shippingstatecode", "datatype": dbt.type_string()}, {"name": "shipping_street", "datatype": dbt.type_string()}, + {"name": "shippingstreet", "datatype": dbt.type_string()}, {"name": "type", "datatype": dbt.type_string()}, {"name": "website", "datatype": dbt.type_string()} ] %} diff --git a/macros/get_contact_columns.sql b/macros/get_contact_columns.sql index 3185589..b4f9767 100644 --- a/macros/get_contact_columns.sql +++ b/macros/get_contact_columns.sql @@ -4,35 +4,58 @@ {"name": "_fivetran_synced", "datatype": dbt.type_timestamp()}, {"name": "_fivetran_active", "datatype": "boolean"}, {"name": "account_id", "datatype": dbt.type_string()}, + {"name": "accountid", "datatype": dbt.type_string()}, {"name": "department", "datatype": dbt.type_string()}, {"name": "description", "datatype": dbt.type_string()}, {"name": "email", "datatype": dbt.type_string()}, {"name": "first_name", "datatype": dbt.type_string()}, + {"name": "firstname", "datatype": dbt.type_string()}, {"name": "home_phone", "datatype": dbt.type_string()}, + {"name": "homephone", "datatype": dbt.type_string()}, {"name": "id", "datatype": dbt.type_string()}, {"name": "individual_id", "datatype": dbt.type_string()}, + {"name": "individualid", "datatype": dbt.type_string()}, {"name": "is_deleted", "datatype": "boolean"}, + {"name": "isdeleted", "datatype": "boolean"}, {"name": "last_activity_date", "datatype": dbt.type_timestamp()}, + {"name": "lastactivitydate", "datatype": dbt.type_timestamp()}, {"name": "last_modified_by_id", "datatype": dbt.type_string()}, + {"name": "lastmodifiedbyid", "datatype": dbt.type_string()}, {"name": "last_modified_date", "datatype": dbt.type_timestamp()}, + {"name": "lastmodifieddate", "datatype": dbt.type_timestamp()}, {"name": "last_name", "datatype": dbt.type_string()}, + {"name": "lastname", "datatype": dbt.type_string()}, {"name": "last_referenced_date", "datatype": dbt.type_timestamp()}, + {"name": "lastreferenceddate", "datatype": dbt.type_timestamp()}, {"name": "last_viewed_date", "datatype": dbt.type_timestamp()}, + {"name": "lastvieweddate", "datatype": dbt.type_timestamp()}, {"name": "lead_source", "datatype": dbt.type_string()}, + {"name": "leadsource", "datatype": dbt.type_string()}, {"name": "mailing_city", "datatype": dbt.type_string()}, + {"name": "mailingcity", "datatype": dbt.type_string()}, {"name": "mailing_country", "datatype": dbt.type_string()}, + {"name": "mailingcountry", "datatype": dbt.type_string()}, {"name": "mailing_country_code", "datatype": dbt.type_string()}, + {"name": "mailingcountrycode", "datatype": dbt.type_string()}, {"name": "mailing_postal_code", "datatype": dbt.type_string()}, + {"name": "mailingpostalcode", "datatype": dbt.type_string()}, {"name": "mailing_state", "datatype": dbt.type_string()}, + {"name": "mailingstate", "datatype": dbt.type_string()}, {"name": "mailing_state_code", "datatype": dbt.type_string()}, + {"name": "mailingstatecode", "datatype": dbt.type_string()}, {"name": "mailing_street", "datatype": dbt.type_string()}, + {"name": "mailingstreet", "datatype": dbt.type_string()}, {"name": "master_record_id", "datatype": dbt.type_string()}, + {"name": "masterrecordid", "datatype": dbt.type_string()}, {"name": "mobile_phone", "datatype": dbt.type_string()}, + {"name": "mobilephone", "datatype": dbt.type_string()}, {"name": "name", "datatype": dbt.type_string()}, {"name": "owner_id", "datatype": dbt.type_string()}, + {"name": "ownerid", "datatype": dbt.type_string()}, {"name": "phone", "datatype": dbt.type_string()}, {"name": "reports_to_id", "datatype": dbt.type_string()}, - {"name": "title", "datatype": dbt.type_string()}, + {"name": "reportstoid", "datatype": dbt.type_string()}, + {"name": "title", "datatype": dbt.type_string()} ] %} {{ fivetran_utils.add_pass_through_columns(columns, var('salesforce__contact_pass_through_columns')) }} diff --git a/macros/get_event_columns.sql b/macros/get_event_columns.sql index e1d2573..843db2a 100644 --- a/macros/get_event_columns.sql +++ b/macros/get_event_columns.sql @@ -4,32 +4,54 @@ {"name": "_fivetran_synced", "datatype": dbt.type_timestamp()}, {"name": "_fivetran_active", "datatype": "boolean"}, {"name": "account_id", "datatype": dbt.type_string()}, + {"name": "accountid", "datatype": dbt.type_string()}, {"name": "activity_date", "datatype": dbt.type_timestamp()}, + {"name": "activitydate", "datatype": dbt.type_timestamp()}, {"name": "activity_date_time", "datatype": dbt.type_timestamp()}, + {"name": "activitydatetime", "datatype": dbt.type_timestamp()}, {"name": "created_by_id", "datatype": dbt.type_string()}, + {"name": "createdbyid", "datatype": dbt.type_string()}, {"name": "created_date", "datatype": dbt.type_timestamp()}, + {"name": "createddate", "datatype": dbt.type_timestamp()}, {"name": "description", "datatype": dbt.type_string()}, {"name": "end_date", "datatype": dbt.type_timestamp()}, + {"name": "enddate", "datatype": dbt.type_timestamp()}, {"name": "end_date_time", "datatype": dbt.type_timestamp()}, + {"name": "enddatetime", "datatype": dbt.type_timestamp()}, {"name": "event_subtype", "datatype": dbt.type_string()}, + {"name": "eventsubtype", "datatype": dbt.type_string()}, {"name": "group_event_type", "datatype": dbt.type_string()}, + {"name": "groupeventtype", "datatype": dbt.type_string()}, {"name": "id", "datatype": dbt.type_string()}, {"name": "is_archived", "datatype": "boolean"}, + {"name": "isarchived", "datatype": "boolean"}, {"name": "is_child", "datatype": "boolean"}, + {"name": "ischild", "datatype": "boolean"}, {"name": "is_deleted", "datatype": "boolean"}, + {"name": "isdeleted", "datatype": "boolean"}, {"name": "is_group_event", "datatype": "boolean"}, + {"name": "isgroupevent", "datatype": "boolean"}, {"name": "is_recurrence", "datatype": "boolean"}, + {"name": "isrecurrence", "datatype": "boolean"}, {"name": "last_modified_by_id", "datatype": dbt.type_string()}, + {"name": "lastmodifiedbyid", "datatype": dbt.type_string()}, {"name": "last_modified_date", "datatype": dbt.type_timestamp()}, + {"name": "lastmodifieddate", "datatype": dbt.type_timestamp()}, {"name": "location", "datatype": dbt.type_string()}, {"name": "owner_id", "datatype": dbt.type_string()}, + {"name": "ownerid", "datatype": dbt.type_string()}, {"name": "start_date_time", "datatype": dbt.type_timestamp()}, + {"name": "startdatetime", "datatype": dbt.type_timestamp()}, {"name": "subject", "datatype": dbt.type_string()}, {"name": "type", "datatype": dbt.type_string()}, {"name": "what_count", "datatype": dbt.type_int()}, + {"name": "whatcount", "datatype": dbt.type_int()}, {"name": "what_id", "datatype": dbt.type_string()}, + {"name": "whatid", "datatype": dbt.type_string()}, {"name": "who_count", "datatype": dbt.type_int()}, - {"name": "who_id", "datatype": dbt.type_string()} + {"name": "whocount", "datatype": dbt.type_int()}, + {"name": "who_id", "datatype": dbt.type_string()}, + {"name": "whoid", "datatype": dbt.type_string()} ] %} {{ fivetran_utils.add_pass_through_columns(columns, var('salesforce__event_pass_through_columns')) }} diff --git a/macros/get_lead_columns.sql b/macros/get_lead_columns.sql index ef8f556..b04d25f 100644 --- a/macros/get_lead_columns.sql +++ b/macros/get_lead_columns.sql @@ -4,48 +4,77 @@ {"name": "_fivetran_synced", "datatype": dbt.type_timestamp()}, {"name": "_fivetran_active", "datatype": "boolean"}, {"name": "annual_revenue", "datatype": dbt.type_float()}, + {"name": "annualrevenue", "datatype": dbt.type_float()}, {"name": "city", "datatype": dbt.type_string()}, {"name": "company", "datatype": dbt.type_string()}, {"name": "converted_account_id", "datatype": dbt.type_string()}, + {"name": "convertedaccountid", "datatype": dbt.type_string()}, {"name": "converted_contact_id", "datatype": dbt.type_string()}, + {"name": "convertedcontactid", "datatype": dbt.type_string()}, {"name": "converted_date", "datatype": dbt.type_timestamp()}, + {"name": "converteddate", "datatype": dbt.type_timestamp()}, {"name": "converted_opportunity_id", "datatype": dbt.type_string()}, + {"name": "convertedopportunityid", "datatype": dbt.type_string()}, {"name": "country", "datatype": dbt.type_string()}, {"name": "country_code", "datatype": dbt.type_string()}, + {"name": "countrycode", "datatype": dbt.type_string()}, {"name": "created_by_id", "datatype": dbt.type_string()}, + {"name": "createdbyid", "datatype": dbt.type_string()}, {"name": "created_date", "datatype": dbt.type_timestamp()}, + {"name": "createddate", "datatype": dbt.type_timestamp()}, {"name": "description", "datatype": dbt.type_string()}, {"name": "email", "datatype": dbt.type_string()}, {"name": "email_bounced_date", "datatype": dbt.type_timestamp()}, + {"name": "emailbounceddate", "datatype": dbt.type_timestamp()}, {"name": "email_bounced_reason", "datatype": dbt.type_string()}, + {"name": "emailbouncedreason", "datatype": dbt.type_string()}, {"name": "first_name", "datatype": dbt.type_string()}, + {"name": "firstname", "datatype": dbt.type_string()}, {"name": "has_opted_out_of_email", "datatype": "boolean"}, + {"name": "hasoptedoutofemail", "datatype": "boolean"}, {"name": "id", "datatype": dbt.type_string()}, {"name": "individual_id", "datatype": dbt.type_string()}, + {"name": "individualid", "datatype": dbt.type_string()}, {"name": "industry", "datatype": dbt.type_string()}, {"name": "is_converted", "datatype": "boolean"}, + {"name": "isconverted", "datatype": "boolean"}, {"name": "is_deleted", "datatype": "boolean"}, + {"name": "isdeleted", "datatype": "boolean"}, {"name": "is_unread_by_owner", "datatype": "boolean"}, + {"name": "isunreadbyowner", "datatype": "boolean"}, {"name": "last_activity_date", "datatype": dbt.type_timestamp()}, + {"name": "lastactivitydate", "datatype": dbt.type_timestamp()}, {"name": "last_modified_by_id", "datatype": dbt.type_string()}, + {"name": "lastmodifiedbyid", "datatype": dbt.type_string()}, {"name": "last_modified_date", "datatype": dbt.type_timestamp()}, + {"name": "lastmodifieddate", "datatype": dbt.type_timestamp()}, {"name": "last_name", "datatype": dbt.type_string()}, + {"name": "lastname", "datatype": dbt.type_string()}, {"name": "last_referenced_date", "datatype": dbt.type_timestamp()}, + {"name": "lastreferenceddate", "datatype": dbt.type_timestamp()}, {"name": "last_viewed_date", "datatype": dbt.type_timestamp()}, + {"name": "lastvieweddate", "datatype": dbt.type_timestamp()}, {"name": "lead_source", "datatype": dbt.type_string()}, + {"name": "leadsource", "datatype": dbt.type_string()}, {"name": "master_record_id", "datatype": dbt.type_string()}, + {"name": "masterrecordid", "datatype": dbt.type_string()}, {"name": "mobile_phone", "datatype": dbt.type_string()}, + {"name": "mobilephone", "datatype": dbt.type_string()}, {"name": "name", "datatype": dbt.type_string()}, {"name": "number_of_employees", "datatype": dbt.type_int()}, + {"name": "numberofemployees", "datatype": dbt.type_int()}, {"name": "owner_id", "datatype": dbt.type_string()}, + {"name": "ownerid", "datatype": dbt.type_string()}, {"name": "phone", "datatype": dbt.type_string()}, {"name": "postal_code", "datatype": dbt.type_string()}, + {"name": "postalcode", "datatype": dbt.type_string()}, {"name": "state", "datatype": dbt.type_string()}, {"name": "state_code", "datatype": dbt.type_string()}, + {"name": "statecode", "datatype": dbt.type_string()}, {"name": "status", "datatype": dbt.type_string()}, {"name": "street", "datatype": dbt.type_string()}, {"name": "title", "datatype": dbt.type_string()}, - {"name": "website", "datatype": dbt.type_string()}, + {"name": "website", "datatype": dbt.type_string()} ] %} {{ fivetran_utils.add_pass_through_columns(columns, var('salesforce__lead_pass_through_columns')) }} diff --git a/macros/get_opportunity_columns.sql b/macros/get_opportunity_columns.sql index cb107e4..d4c47db 100644 --- a/macros/get_opportunity_columns.sql +++ b/macros/get_opportunity_columns.sql @@ -5,36 +5,60 @@ {"name": "_fivetran_synced", "datatype": dbt.type_timestamp()}, {"name": "_fivetran_active", "datatype": "boolean"}, {"name": "account_id", "datatype": dbt.type_string()}, + {"name": "accountid", "datatype": dbt.type_string()}, {"name": "amount", "datatype": dbt.type_float()}, {"name": "campaign_id", "datatype": dbt.type_string()}, + {"name": "campaignid", "datatype": dbt.type_string()}, {"name": "close_date", "datatype": dbt.type_timestamp()}, + {"name": "closedate", "datatype": dbt.type_timestamp()}, {"name": "created_date", "datatype": dbt.type_timestamp()}, + {"name": "createddate", "datatype": dbt.type_timestamp()}, {"name": "description", "datatype": dbt.type_string()}, {"name": "expected_revenue", "datatype": dbt.type_numeric()}, + {"name": "expectedrevenue", "datatype": dbt.type_numeric()}, {"name": "fiscal", "datatype": dbt.type_string()}, {"name": "fiscal_quarter", "datatype": dbt.type_int()}, + {"name": "fiscalquarter", "datatype": dbt.type_int()}, {"name": "fiscal_year", "datatype": dbt.type_int()}, + {"name": "fiscalyear", "datatype": dbt.type_int()}, {"name": "forecast_category", "datatype": dbt.type_string()}, + {"name": "forecastcategory", "datatype": dbt.type_string()}, {"name": "forecast_category_name", "datatype": dbt.type_string()}, + {"name": "forecastcategoryname", "datatype": dbt.type_string()}, {"name": "has_open_activity", "datatype": "boolean"}, + {"name": "hasopenactivity", "datatype": "boolean"}, {"name": "has_opportunity_line_item", "datatype": "boolean"}, + {"name": "hasopportunitylineitem", "datatype": "boolean"}, {"name": "has_overdue_task", "datatype": "boolean"}, + {"name": "hasoverduetask", "datatype": "boolean"}, {"name": "id", "datatype": dbt.type_string()}, {"name": "is_closed", "datatype": "boolean"}, + {"name": "isclosed", "datatype": "boolean"}, {"name": "is_deleted", "datatype": "boolean"}, + {"name": "isdeleted", "datatype": "boolean"}, {"name": "is_won", "datatype": "boolean"}, + {"name": "iswon", "datatype": "boolean"}, {"name": "last_activity_date", "datatype": dbt.type_timestamp()}, + {"name": "lastactivitydate", "datatype": dbt.type_timestamp()}, {"name": "last_referenced_date", "datatype": dbt.type_timestamp()}, + {"name": "lastreferenceddate", "datatype": dbt.type_timestamp()}, {"name": "last_viewed_date", "datatype": dbt.type_timestamp()}, + {"name": "lastvieweddate", "datatype": dbt.type_timestamp()}, {"name": "lead_source", "datatype": dbt.type_string()}, + {"name": "leadsource", "datatype": dbt.type_string()}, {"name": "name", "datatype": dbt.type_string()}, {"name": "next_step", "datatype": dbt.type_string()}, + {"name": "nextstep", "datatype": dbt.type_string()}, {"name": "owner_id", "datatype": dbt.type_string()}, + {"name": "ownerid", "datatype": dbt.type_string()}, {"name": "probability", "datatype": dbt.type_float()}, {"name": "record_type_id", "datatype": dbt.type_string()}, + {"name": "recordtypeid", "datatype": dbt.type_string()}, {"name": "stage_name", "datatype": dbt.type_string()}, + {"name": "stagename", "datatype": dbt.type_string()}, {"name": "synced_quote_id", "datatype": dbt.type_string()}, - {"name": "type", "datatype": dbt.type_string()}, + {"name": "syncedquoteid", "datatype": dbt.type_string()}, + {"name": "type", "datatype": dbt.type_string()} ] %} {{ fivetran_utils.add_pass_through_columns(columns, var('salesforce__opportunity_pass_through_columns')) }} diff --git a/macros/get_opportunity_line_item_columns.sql b/macros/get_opportunity_line_item_columns.sql index 5b26f44..0360d6c 100644 --- a/macros/get_opportunity_line_item_columns.sql +++ b/macros/get_opportunity_line_item_columns.sql @@ -4,29 +4,48 @@ {"name": "_fivetran_synced", "datatype": dbt.type_timestamp()}, {"name": "_fivetran_active", "datatype": "boolean"}, {"name": "created_by_id", "datatype": dbt.type_string()}, + {"name": "createdbyid", "datatype": dbt.type_string()}, {"name": "created_date", "datatype": dbt.type_timestamp()}, + {"name": "createddate", "datatype": dbt.type_timestamp()}, {"name": "description", "datatype": dbt.type_string()}, {"name": "discount", "datatype": dbt.type_float()}, {"name": "has_quantity_schedule", "datatype": "boolean"}, + {"name": "hasquantityschedule", "datatype": "boolean"}, {"name": "has_revenue_schedule", "datatype": "boolean"}, + {"name": "hasrevenueschedule", "datatype": "boolean"}, {"name": "has_schedule", "datatype": "boolean"}, + {"name": "hasschedule", "datatype": "boolean"}, {"name": "id", "datatype": dbt.type_string()}, {"name": "is_deleted", "datatype": "boolean"}, + {"name": "isdeleted", "datatype": "boolean"}, {"name": "last_modified_by_id", "datatype": dbt.type_string()}, + {"name": "lastmodifiedbyid", "datatype": dbt.type_string()}, {"name": "last_modified_date", "datatype": dbt.type_timestamp()}, + {"name": "lastmodifieddate", "datatype": dbt.type_timestamp()}, {"name": "last_referenced_date", "datatype": dbt.type_timestamp()}, + {"name": "lastreferenceddate", "datatype": dbt.type_timestamp()}, {"name": "last_viewed_date", "datatype": dbt.type_timestamp()}, + {"name": "lastvieweddate", "datatype": dbt.type_timestamp()}, {"name": "list_price", "datatype": dbt.type_float()}, + {"name": "listprice", "datatype": dbt.type_float()}, {"name": "name", "datatype": dbt.type_string()}, {"name": "opportunity_id", "datatype": dbt.type_string()}, + {"name": "opportunityid", "datatype": dbt.type_string()}, {"name": "pricebook_entry_id", "datatype": dbt.type_string()}, + {"name": "pricebookentryid", "datatype": dbt.type_string()}, {"name": "product_2_id", "datatype": dbt.type_string()}, + {"name": "product2id", "datatype": dbt.type_string()}, {"name": "product_code", "datatype": dbt.type_string()}, + {"name": "productcode", "datatype": dbt.type_string()}, {"name": "quantity", "datatype": dbt.type_float()}, {"name": "service_date", "datatype": dbt.type_timestamp()}, + {"name": "servicedate", "datatype": dbt.type_timestamp()}, {"name": "sort_order", "datatype": dbt.type_int()}, + {"name": "sortorder", "datatype": dbt.type_int()}, {"name": "total_price", "datatype": dbt.type_float()}, - {"name": "unit_price", "datatype": dbt.type_float()} + {"name": "totalprice", "datatype": dbt.type_float()}, + {"name": "unit_price", "datatype": dbt.type_float()}, + {"name": "unitprice", "datatype": dbt.type_float()} ] %} {{ fivetran_utils.add_pass_through_columns(columns, var('salesforce__opportunity_line_item_pass_through_columns')) }} diff --git a/macros/get_order_columns.sql b/macros/get_order_columns.sql index 96f857a..86559c0 100644 --- a/macros/get_order_columns.sql +++ b/macros/get_order_columns.sql @@ -4,41 +4,73 @@ {"name": "_fivetran_synced", "datatype": dbt.type_timestamp()}, {"name": "_fivetran_active", "datatype": "boolean"}, {"name": "account_id", "datatype": dbt.type_string()}, + {"name": "accountid", "datatype": dbt.type_string()}, {"name": "activated_by_id", "datatype": dbt.type_string()}, + {"name": "activatedbyid", "datatype": dbt.type_string()}, {"name": "activated_date", "datatype": dbt.type_timestamp()}, + {"name": "activateddate", "datatype": dbt.type_timestamp()}, {"name": "billing_city", "datatype": dbt.type_string()}, + {"name": "billingcity", "datatype": dbt.type_string()}, {"name": "billing_country", "datatype": dbt.type_string()}, + {"name": "billingcountry", "datatype": dbt.type_string()}, {"name": "billing_country_code", "datatype": dbt.type_string()}, + {"name": "billingcountrycode", "datatype": dbt.type_string()}, {"name": "billing_postal_code", "datatype": dbt.type_string()}, + {"name": "billingpostalcode", "datatype": dbt.type_string()}, {"name": "billing_state", "datatype": dbt.type_string()}, + {"name": "billingstate", "datatype": dbt.type_string()}, {"name": "billing_state_code", "datatype": dbt.type_string()}, + {"name": "billingstatecode", "datatype": dbt.type_string()}, {"name": "billing_street", "datatype": dbt.type_string()}, + {"name": "billingstreet", "datatype": dbt.type_string()}, {"name": "contract_id", "datatype": dbt.type_string()}, + {"name": "contractid", "datatype": dbt.type_string()}, {"name": "created_by_id", "datatype": dbt.type_string()}, + {"name": "createdbyid", "datatype": dbt.type_string()}, {"name": "created_date", "datatype": dbt.type_timestamp()}, + {"name": "createddate", "datatype": dbt.type_timestamp()}, {"name": "description", "datatype": dbt.type_string()}, {"name": "end_date", "datatype": dbt.type_timestamp()}, + {"name": "enddate", "datatype": dbt.type_timestamp()}, {"name": "id", "datatype": dbt.type_string()}, {"name": "is_deleted", "datatype": "boolean"}, + {"name": "isdeleted", "datatype": "boolean"}, {"name": "last_modified_by_id", "datatype": dbt.type_string()}, + {"name": "lastmodifiedbyid", "datatype": dbt.type_string()}, {"name": "last_modified_date", "datatype": dbt.type_timestamp()}, + {"name": "lastmodifieddate", "datatype": dbt.type_timestamp()}, {"name": "last_referenced_date", "datatype": dbt.type_timestamp()}, + {"name": "lastreferenceddate", "datatype": dbt.type_timestamp()}, {"name": "last_viewed_date", "datatype": dbt.type_timestamp()}, + {"name": "lastvieweddate", "datatype": dbt.type_timestamp()}, {"name": "opportunity_id", "datatype": dbt.type_string()}, + {"name": "opportunityid", "datatype": dbt.type_string()}, {"name": "order_number", "datatype": dbt.type_string()}, + {"name": "ordernumber", "datatype": dbt.type_string()}, {"name": "original_order_id", "datatype": dbt.type_string()}, + {"name": "originalorderid", "datatype": dbt.type_string()}, {"name": "owner_id", "datatype": dbt.type_string()}, + {"name": "ownerid", "datatype": dbt.type_string()}, {"name": "pricebook_2_id", "datatype": dbt.type_string()}, + {"name": "pricebook2id", "datatype": dbt.type_string()}, {"name": "shipping_city", "datatype": dbt.type_string()}, + {"name": "shippingcity", "datatype": dbt.type_string()}, {"name": "shipping_country", "datatype": dbt.type_string()}, + {"name": "shippingcountry", "datatype": dbt.type_string()}, {"name": "shipping_country_code", "datatype": dbt.type_string()}, + {"name": "shippingcountrycode", "datatype": dbt.type_string()}, {"name": "shipping_postal_code", "datatype": dbt.type_string()}, + {"name": "shippingpostalcode", "datatype": dbt.type_string()}, {"name": "shipping_state", "datatype": dbt.type_string()}, + {"name": "shippingstate", "datatype": dbt.type_string()}, {"name": "shipping_state_code", "datatype": dbt.type_string()}, + {"name": "shippingstatecode", "datatype": dbt.type_string()}, {"name": "shipping_street", "datatype": dbt.type_string()}, + {"name": "shippingstreet", "datatype": dbt.type_string()}, {"name": "status", "datatype": dbt.type_string()}, {"name": "total_amount", "datatype": dbt.type_float()}, - {"name": "type", "datatype": dbt.type_string()}, + {"name": "totalamount", "datatype": dbt.type_float()}, + {"name": "type", "datatype": dbt.type_string()} ] %} {{ fivetran_utils.add_pass_through_columns(columns, var('salesforce__order_pass_through_columns')) }} diff --git a/macros/get_product_2_columns.sql b/macros/get_product_2_columns.sql index 3fcb77b..9f2c223 100644 --- a/macros/get_product_2_columns.sql +++ b/macros/get_product_2_columns.sql @@ -4,29 +4,49 @@ {"name": "_fivetran_synced", "datatype": dbt.type_timestamp()}, {"name": "_fivetran_active", "datatype": "boolean"}, {"name": "created_by_id", "datatype": dbt.type_string()}, + {"name": "createdbyid", "datatype": dbt.type_string()}, {"name": "created_date", "datatype": dbt.type_timestamp()}, + {"name": "createddate", "datatype": dbt.type_timestamp()}, {"name": "description", "datatype": dbt.type_string()}, {"name": "display_url", "datatype": dbt.type_string()}, + {"name": "displayurl", "datatype": dbt.type_string()}, {"name": "external_id", "datatype": dbt.type_string()}, + {"name": "externalid", "datatype": dbt.type_string()}, {"name": "family", "datatype": dbt.type_string()}, {"name": "id", "datatype": dbt.type_string()}, {"name": "is_active", "datatype": "boolean"}, + {"name": "isactive", "datatype": "boolean"}, {"name": "is_archived", "datatype": "boolean"}, + {"name": "isarchived", "datatype": "boolean"}, {"name": "is_deleted", "datatype": "boolean"}, + {"name": "isdeleted", "datatype": "boolean"}, {"name": "last_modified_by_id", "datatype": dbt.type_string()}, + {"name": "lastmodifiedbyid", "datatype": dbt.type_string()}, {"name": "last_modified_date", "datatype": dbt.type_timestamp()}, + {"name": "lastmodifieddate", "datatype": dbt.type_timestamp()}, {"name": "last_referenced_date", "datatype": dbt.type_timestamp()}, + {"name": "lastreferenceddate", "datatype": dbt.type_timestamp()}, {"name": "last_viewed_date", "datatype": dbt.type_timestamp()}, + {"name": "lastvieweddate", "datatype": dbt.type_timestamp()}, {"name": "name", "datatype": dbt.type_string()}, {"name": "number_of_quantity_installments", "datatype": dbt.type_int()}, + {"name": "numberofquantityinstallments", "datatype": dbt.type_int()}, {"name": "number_of_revenue_installments", "datatype": dbt.type_int()}, + {"name": "numberofrevenueinstallments", "datatype": dbt.type_int()}, {"name": "product_code", "datatype": dbt.type_string()}, + {"name": "productcode", "datatype": dbt.type_string()}, {"name": "quantity_installment_period", "datatype": dbt.type_string()}, + {"name": "quantityinstallmentperiod", "datatype": dbt.type_string()}, {"name": "quantity_schedule_type", "datatype": dbt.type_string()}, + {"name": "quantityscheduletype", "datatype": dbt.type_string()}, {"name": "quantity_unit_of_measure", "datatype": dbt.type_string()}, + {"name": "quantityunitofmeasure", "datatype": dbt.type_string()}, {"name": "record_type_id", "datatype": dbt.type_string()}, + {"name": "recordtypeid", "datatype": dbt.type_string()}, {"name": "revenue_installment_period", "datatype": dbt.type_string()}, + {"name": "revenueinstallmentperiod", "datatype": dbt.type_string()}, {"name": "revenue_schedule_type", "datatype": dbt.type_string()}, + {"name": "revenuescheduletype", "datatype": dbt.type_string()} ] %} {{ fivetran_utils.add_pass_through_columns(columns, var('salesforce__product_2_pass_through_columns')) }} diff --git a/macros/get_task_columns.sql b/macros/get_task_columns.sql index d062e6c..802451d 100644 --- a/macros/get_task_columns.sql +++ b/macros/get_task_columns.sql @@ -4,33 +4,55 @@ {"name": "_fivetran_synced", "datatype": dbt.type_timestamp()}, {"name": "_fivetran_active", "datatype": "boolean"}, {"name": "account_id", "datatype": dbt.type_string()}, + {"name": "accountid", "datatype": dbt.type_string()}, {"name": "activity_date", "datatype": dbt.type_timestamp()}, + {"name": "activitydate", "datatype": dbt.type_timestamp()}, {"name": "call_disposition", "datatype": dbt.type_string()}, + {"name": "calldisposition", "datatype": dbt.type_string()}, {"name": "call_duration_in_seconds", "datatype": dbt.type_int()}, + {"name": "calldurationinseconds", "datatype": dbt.type_int()}, {"name": "call_object", "datatype": dbt.type_string()}, + {"name": "callobject", "datatype": dbt.type_string()}, {"name": "call_type", "datatype": dbt.type_string()}, + {"name": "calltype", "datatype": dbt.type_string()}, {"name": "completed_date_time", "datatype": dbt.type_timestamp()}, + {"name": "completeddatetime", "datatype": dbt.type_timestamp()}, {"name": "created_by_id", "datatype": dbt.type_string()}, + {"name": "createdbyid", "datatype": dbt.type_string()}, {"name": "created_date", "datatype": dbt.type_timestamp()}, + {"name": "createddate", "datatype": dbt.type_timestamp()}, {"name": "description", "datatype": dbt.type_string()}, {"name": "id", "datatype": dbt.type_string()}, {"name": "is_archived", "datatype": "boolean"}, + {"name": "isarchived", "datatype": "boolean"}, {"name": "is_closed", "datatype": "boolean"}, + {"name": "isclosed", "datatype": "boolean"}, {"name": "is_deleted", "datatype": "boolean"}, + {"name": "isdeleted", "datatype": "boolean"}, {"name": "is_high_priority", "datatype": "boolean"}, + {"name": "ishighpriority", "datatype": "boolean"}, {"name": "last_modified_by_id", "datatype": dbt.type_string()}, + {"name": "lastmodifiedbyid", "datatype": dbt.type_string()}, {"name": "last_modified_date", "datatype": dbt.type_timestamp()}, + {"name": "lastmodifieddate", "datatype": dbt.type_timestamp()}, {"name": "owner_id", "datatype": dbt.type_string()}, + {"name": "ownerid", "datatype": dbt.type_string()}, {"name": "priority", "datatype": dbt.type_string()}, {"name": "record_type_id", "datatype": dbt.type_string()}, + {"name": "recordtypeid", "datatype": dbt.type_string()}, {"name": "status", "datatype": dbt.type_string()}, {"name": "subject", "datatype": dbt.type_string()}, {"name": "task_subtype", "datatype": dbt.type_string()}, + {"name": "tasksubtype", "datatype": dbt.type_string()}, {"name": "type", "datatype": dbt.type_string()}, {"name": "what_count", "datatype": dbt.type_int()}, + {"name": "whatcount", "datatype": dbt.type_int()}, {"name": "what_id", "datatype": dbt.type_string()}, + {"name": "whatid", "datatype": dbt.type_string()}, {"name": "who_count", "datatype": dbt.type_int()}, - {"name": "who_id", "datatype": dbt.type_string()} + {"name": "whocount", "datatype": dbt.type_int()}, + {"name": "who_id", "datatype": dbt.type_string()}, + {"name": "whoid", "datatype": dbt.type_string()} ] %} {{ fivetran_utils.add_pass_through_columns(columns, var('salesforce__task_pass_through_columns')) }} diff --git a/macros/get_user_columns.sql b/macros/get_user_columns.sql index 25e4858..4062aec 100644 --- a/macros/get_user_columns.sql +++ b/macros/get_user_columns.sql @@ -5,33 +5,50 @@ {"name": "_fivetran_active", "datatype": "boolean"}, {"name": "_fivetran_synced", "datatype": dbt.type_timestamp()}, {"name": "account_id", "datatype": dbt.type_string()}, + {"name": "accountid", "datatype": dbt.type_string()}, {"name": "alias", "datatype": dbt.type_string()}, {"name": "city", "datatype": dbt.type_string()}, {"name": "company_name", "datatype": dbt.type_string()}, + {"name": "companyname", "datatype": dbt.type_string()}, {"name": "contact_id", "datatype": dbt.type_string()}, + {"name": "contactid", "datatype": dbt.type_string()}, {"name": "country", "datatype": dbt.type_string()}, {"name": "country_code", "datatype": dbt.type_string()}, + {"name": "countrycode", "datatype": dbt.type_string()}, {"name": "department", "datatype": dbt.type_string()}, {"name": "email", "datatype": dbt.type_string()}, {"name": "first_name", "datatype": dbt.type_string()}, + {"name": "firstname", "datatype": dbt.type_string()}, {"name": "id", "datatype": dbt.type_string()}, {"name": "individual_id", "datatype": dbt.type_string()}, + {"name": "individualid", "datatype": dbt.type_string()}, {"name": "is_active", "datatype": "boolean"}, + {"name": "isactive", "datatype": "boolean"}, {"name": "last_login_date", "datatype": dbt.type_timestamp()}, + {"name": "lastlogindate", "datatype": dbt.type_timestamp()}, {"name": "last_name", "datatype": dbt.type_string()}, + {"name": "lastname", "datatype": dbt.type_string()}, {"name": "last_referenced_date", "datatype": dbt.type_timestamp()}, + {"name": "lastreferenceddate", "datatype": dbt.type_timestamp()}, {"name": "last_viewed_date", "datatype": dbt.type_timestamp()}, + {"name": "lastvieweddate", "datatype": dbt.type_timestamp()}, {"name": "manager_id", "datatype": dbt.type_string()}, + {"name": "managerid", "datatype": dbt.type_string()}, {"name": "name", "datatype": dbt.type_string()}, {"name": "postal_code", "datatype": dbt.type_string()}, + {"name": "postalcode", "datatype": dbt.type_string()}, {"name": "profile_id", "datatype": dbt.type_string()}, + {"name": "profileid", "datatype": dbt.type_string()}, {"name": "state", "datatype": dbt.type_string()}, {"name": "state_code", "datatype": dbt.type_string()}, + {"name": "statecode", "datatype": dbt.type_string()}, {"name": "street", "datatype": dbt.type_string()}, {"name": "title", "datatype": dbt.type_string()}, {"name": "user_role_id", "datatype": dbt.type_string()}, + {"name": "userroleid", "datatype": dbt.type_string()}, {"name": "user_type", "datatype": dbt.type_string()}, - {"name": "username", "datatype": dbt.type_string()}, + {"name": "usertype", "datatype": dbt.type_string()}, + {"name": "username", "datatype": dbt.type_string()} ] %} {{ fivetran_utils.add_pass_through_columns(columns, var('salesforce__user_pass_through_columns')) }} diff --git a/macros/get_user_role_columns.sql b/macros/get_user_role_columns.sql index 31ffe96..f483b86 100644 --- a/macros/get_user_role_columns.sql +++ b/macros/get_user_role_columns.sql @@ -5,11 +5,15 @@ {"name": "_fivetran_active", "datatype": "boolean"}, {"name": "_fivetran_synced", "datatype": dbt.type_timestamp()}, {"name": "developer_name", "datatype": dbt.type_string()}, + {"name": "developername", "datatype": dbt.type_string()}, {"name": "id", "datatype": dbt.type_string()}, {"name": "name", "datatype": dbt.type_string()}, {"name": "opportunity_access_for_account_owner", "datatype": dbt.type_string()}, + {"name": "opportunityaccessforaccountowner", "datatype": dbt.type_string()}, {"name": "parent_role_id", "datatype": dbt.type_string()}, - {"name": "rollup_description", "datatype": dbt.type_string()} + {"name": "parentroleid", "datatype": dbt.type_string()}, + {"name": "rollup_description", "datatype": dbt.type_string()}, + {"name": "rollupdescription", "datatype": dbt.type_string()} ] %} {{ fivetran_utils.add_pass_through_columns(columns, var('salesforce__user_role_pass_through_columns')) }} diff --git a/models/salesforce/stg_salesforce__account.sql b/models/salesforce/stg_salesforce__account.sql index a796894..dc47bd8 100644 --- a/models/salesforce/stg_salesforce__account.sql +++ b/models/salesforce/stg_salesforce__account.sql @@ -16,37 +16,37 @@ final as ( select cast(_fivetran_synced as {{ dbt.type_timestamp() }}) as _fivetran_synced, - account_number, - account_source, - cast(annual_revenue as {{ dbt.type_numeric() }}) as annual_revenue, - billing_city, - billing_country, - billing_postal_code, - billing_state, - billing_state_code, - billing_street, + {{ coalesce_w_renamed_col('account_number') }}, + {{ coalesce_w_renamed_col('account_source') }}, + {{ coalesce_w_renamed_col('annual_revenue', datatype=dbt.type_numeric()) }}, + {{ coalesce_w_renamed_col('billing_city') }}, + {{ coalesce_w_renamed_col('billing_country') }}, + {{ coalesce_w_renamed_col('billing_postal_code') }}, + {{ coalesce_w_renamed_col('billing_state') }}, + {{ coalesce_w_renamed_col('billing_state_code') }}, + {{ coalesce_w_renamed_col('billing_street') }}, description as account_description, id as account_id, industry, - is_deleted, - cast(last_activity_date as {{ dbt.type_timestamp() }}) as last_activity_date, - cast(last_referenced_date as {{ dbt.type_timestamp() }}) as last_referenced_date, - cast(last_viewed_date as {{ dbt.type_timestamp() }}) as last_viewed_date, - master_record_id, + {{ coalesce_w_renamed_col('is_deleted') }}, + {{ coalesce_w_renamed_col('last_activity_date', datatype=dbt.type_timestamp()) }}, + {{ coalesce_w_renamed_col('last_referenced_date', datatype=dbt.type_timestamp()) }}, + {{ coalesce_w_renamed_col('last_viewed_date', datatype=dbt.type_timestamp()) }}, + {{ coalesce_w_renamed_col('master_record_id') }}, name as account_name, - number_of_employees, - owner_id, + {{ coalesce_w_renamed_col('number_of_employees') }}, + {{ coalesce_w_renamed_col('owner_id') }}, ownership, - parent_id, + {{ coalesce_w_renamed_col('parent_id') }}, rating, - record_type_id, - shipping_city, - shipping_country, - shipping_country_code, - shipping_postal_code, - shipping_state, - shipping_state_code, - shipping_street, + {{ coalesce_w_renamed_col('record_type_id') }}, + {{ coalesce_w_renamed_col('shipping_city') }}, + {{ coalesce_w_renamed_col('shipping_country') }}, + {{ coalesce_w_renamed_col('shipping_country_code') }}, + {{ coalesce_w_renamed_col('shipping_postal_code') }}, + {{ coalesce_w_renamed_col('shipping_state') }}, + {{ coalesce_w_renamed_col('shipping_state_code') }}, + {{ coalesce_w_renamed_col('shipping_street') }}, type, website diff --git a/models/salesforce/stg_salesforce__contact.sql b/models/salesforce/stg_salesforce__contact.sql index c48a335..6516a1d 100644 --- a/models/salesforce/stg_salesforce__contact.sql +++ b/models/salesforce/stg_salesforce__contact.sql @@ -17,34 +17,34 @@ final as ( select cast(_fivetran_synced as {{ dbt.type_timestamp() }}) as _fivetran_synced, id as contact_id, - account_id, + {{ coalesce_w_renamed_col('account_id') }}, department, description as contact_description, email, - first_name, - home_phone, - individual_id, - is_deleted, - cast(last_activity_date as {{ dbt.type_timestamp() }}) as last_activity_date, - last_modified_by_id, - last_modified_date, - last_name, - last_referenced_date, - cast(last_viewed_date as {{ dbt.type_timestamp() }}) as last_viewed_date, - lead_source, - mailing_city, - mailing_country, - mailing_country_code, - mailing_postal_code, - mailing_state, - mailing_state_code, - mailing_street, - master_record_id, - mobile_phone, + {{ coalesce_w_renamed_col('first_name') }}, + {{ coalesce_w_renamed_col('home_phone') }}, + {{ coalesce_w_renamed_col('individual_id') }}, + {{ coalesce_w_renamed_col('is_deleted') }}, + {{ coalesce_w_renamed_col('last_activity_date', datatype=dbt.type_timestamp()) }}, + {{ coalesce_w_renamed_col('last_modified_by_id') }}, + {{ coalesce_w_renamed_col('last_modified_date') }}, + {{ coalesce_w_renamed_col('last_name') }}, + {{ coalesce_w_renamed_col('last_referenced_date') }}, + {{ coalesce_w_renamed_col('last_viewed_date', datatype=dbt.type_timestamp()) }}, + {{ coalesce_w_renamed_col('lead_source') }}, + {{ coalesce_w_renamed_col('mailing_city') }}, + {{ coalesce_w_renamed_col('mailing_country') }}, + {{ coalesce_w_renamed_col('mailing_country_code') }}, + {{ coalesce_w_renamed_col('mailing_postal_code') }}, + {{ coalesce_w_renamed_col('mailing_state') }}, + {{ coalesce_w_renamed_col('mailing_state_code') }}, + {{ coalesce_w_renamed_col('mailing_street') }}, + {{ coalesce_w_renamed_col('master_record_id') }}, + {{ coalesce_w_renamed_col('mobile_phone') }}, name as contact_name, - owner_id, + {{ coalesce_w_renamed_col('owner_id') }}, phone, - reports_to_id, + {{ coalesce_w_renamed_col('reports_to_id') }}, title {{ fivetran_utils.fill_pass_through_columns('salesforce__contact_pass_through_columns') }} diff --git a/models/salesforce/stg_salesforce__event.sql b/models/salesforce/stg_salesforce__event.sql index 2ca794e..cf49f3b 100644 --- a/models/salesforce/stg_salesforce__event.sql +++ b/models/salesforce/stg_salesforce__event.sql @@ -19,32 +19,32 @@ final as ( select cast(_fivetran_synced as {{ dbt.type_timestamp() }}) as _fivetran_synced, id as event_id, - account_id, - cast(activity_date as {{ dbt.type_timestamp() }}) as activity_date, - cast(activity_date_time as {{ dbt.type_timestamp() }}) as activity_date_time, - created_by_id, - cast(created_date as {{ dbt.type_timestamp() }}) as created_date, + {{ coalesce_w_renamed_col('account_id') }}, + {{ coalesce_w_renamed_col('activity_date', datatype=dbt.type_timestamp()) }}, + {{ coalesce_w_renamed_col('activity_date_time', datatype=dbt.type_timestamp()) }}, + {{ coalesce_w_renamed_col('created_by_id') }}, + {{ coalesce_w_renamed_col('created_date', datatype=dbt.type_timestamp()) }}, description as event_description, - cast(end_date as {{ dbt.type_timestamp() }}) as end_date, - cast(end_date_time as {{ dbt.type_timestamp() }}) as end_date_time, - event_subtype, - group_event_type, - is_archived, - is_child, - is_deleted, - is_group_event, - is_recurrence, - last_modified_by_id, - cast(last_modified_date as {{ dbt.type_timestamp() }}) as last_modified_date, + {{ coalesce_w_renamed_col('end_date', datatype=dbt.type_timestamp()) }}, + {{ coalesce_w_renamed_col('end_date_time', datatype=dbt.type_timestamp()) }}, + {{ coalesce_w_renamed_col('event_subtype') }}, + {{ coalesce_w_renamed_col('group_event_type') }}, + {{ coalesce_w_renamed_col('is_archived') }}, + {{ coalesce_w_renamed_col('is_child') }}, + {{ coalesce_w_renamed_col('is_deleted') }}, + {{ coalesce_w_renamed_col('is_group_event') }}, + {{ coalesce_w_renamed_col('is_recurrence') }}, + {{ coalesce_w_renamed_col('last_modified_by_id') }}, + {{ coalesce_w_renamed_col('last_modified_date', datatype=dbt.type_timestamp()) }}, location, - owner_id, - cast(start_date_time as {{ dbt.type_timestamp() }}) as start_date_time, + {{ coalesce_w_renamed_col('owner_id') }}, + {{ coalesce_w_renamed_col('start_date_time', datatype=dbt.type_timestamp()) }}, subject, type, - what_count, - what_id, - who_count, - who_id + {{ coalesce_w_renamed_col('what_count') }}, + {{ coalesce_w_renamed_col('what_id') }}, + {{ coalesce_w_renamed_col('who_count') }}, + {{ coalesce_w_renamed_col('who_id') }} {{ fivetran_utils.fill_pass_through_columns('salesforce__event_pass_through_columns') }} diff --git a/models/salesforce/stg_salesforce__lead.sql b/models/salesforce/stg_salesforce__lead.sql index 0f97da0..1b3cf10 100644 --- a/models/salesforce/stg_salesforce__lead.sql +++ b/models/salesforce/stg_salesforce__lead.sql @@ -19,44 +19,44 @@ final as ( select cast(_fivetran_synced as {{ dbt.type_timestamp() }}) as _fivetran_synced, id as lead_id, - annual_revenue, + {{ coalesce_w_renamed_col('annual_revenue') }}, city, company, - converted_account_id, - converted_contact_id, - cast(converted_date as {{ dbt.type_timestamp() }}) as converted_date, - converted_opportunity_id, + {{ coalesce_w_renamed_col('converted_account_id') }}, + {{ coalesce_w_renamed_col('converted_contact_id') }}, + {{ coalesce_w_renamed_col('converted_date', datatype=dbt.type_timestamp()) }}, + {{ coalesce_w_renamed_col('converted_opportunity_id') }}, country, - country_code, - created_by_id, - cast(created_date as {{ dbt.type_timestamp() }}) as created_date, + {{ coalesce_w_renamed_col('country_code') }}, + {{ coalesce_w_renamed_col('created_by_id') }}, + {{ coalesce_w_renamed_col('created_date', datatype=dbt.type_timestamp()) }}, description as lead_description, email, - cast(email_bounced_date as {{ dbt.type_timestamp() }}) as email_bounced_date, - email_bounced_reason, - first_name, - has_opted_out_of_email, - individual_id, + {{ coalesce_w_renamed_col('email_bounced_date', datatype=dbt.type_timestamp()) }}, + {{ coalesce_w_renamed_col('email_bounced_reason') }}, + {{ coalesce_w_renamed_col('first_name') }}, + {{ coalesce_w_renamed_col('has_opted_out_of_email') }}, + {{ coalesce_w_renamed_col('individual_id') }}, industry, - is_converted, - is_deleted, - is_unread_by_owner, - cast(last_activity_date as {{ dbt.type_timestamp() }}) as last_activity_date, - last_modified_by_id, - cast(last_modified_date as {{ dbt.type_timestamp() }}) as last_modified_date, - last_name, - cast(last_referenced_date as {{ dbt.type_timestamp() }}) as last_referenced_date, - cast(last_viewed_date as {{ dbt.type_timestamp() }}) as last_viewed_date, - lead_source, - master_record_id, - mobile_phone, + {{ coalesce_w_renamed_col('is_converted') }}, + {{ coalesce_w_renamed_col('is_deleted') }}, + {{ coalesce_w_renamed_col('is_unread_by_owner') }}, + {{ coalesce_w_renamed_col('last_activity_date', datatype=dbt.type_timestamp()) }}, + {{ coalesce_w_renamed_col('last_modified_by_id') }}, + {{ coalesce_w_renamed_col('last_modified_date', datatype=dbt.type_timestamp()) }}, + {{ coalesce_w_renamed_col('last_name') }}, + {{ coalesce_w_renamed_col('last_referenced_date', datatype=dbt.type_timestamp()) }}, + {{ coalesce_w_renamed_col('last_viewed_date', datatype=dbt.type_timestamp()) }}, + {{ coalesce_w_renamed_col('lead_source') }}, + {{ coalesce_w_renamed_col('master_record_id') }}, + {{ coalesce_w_renamed_col('mobile_phone') }}, name as lead_name, - number_of_employees, - owner_id, + {{ coalesce_w_renamed_col('number_of_employees') }}, + {{ coalesce_w_renamed_col('owner_id') }}, phone, - postal_code, + {{ coalesce_w_renamed_col('postal_code') }}, state, - state_code, + {{ coalesce_w_renamed_col('state_code') }}, status, street, title, diff --git a/models/salesforce/stg_salesforce__opportunity.sql b/models/salesforce/stg_salesforce__opportunity.sql index e2a87f2..d28f2dd 100644 --- a/models/salesforce/stg_salesforce__opportunity.sql +++ b/models/salesforce/stg_salesforce__opportunity.sql @@ -16,36 +16,36 @@ final as ( select cast(_fivetran_synced as {{ dbt.type_timestamp() }}) as _fivetran_synced, - account_id, + {{ coalesce_w_renamed_col('account_id') }}, cast(amount as {{ dbt.type_numeric() }}) as amount, - campaign_id, - cast(close_date as {{ dbt.type_timestamp() }}) as close_date, - cast(created_date as {{ dbt.type_timestamp() }}) as created_date, + {{ coalesce_w_renamed_col('campaign_id') }}, + {{ coalesce_w_renamed_col('close_date', datatype=dbt.type_timestamp()) }}, + {{ coalesce_w_renamed_col('created_date', datatype=dbt.type_timestamp()) }}, description as opportunity_description, - cast(expected_revenue as {{ dbt.type_numeric() }}) as expected_revenue, + {{ coalesce_w_renamed_col('expected_revenue', datatype=dbt.type_numeric()) }}, fiscal, - fiscal_quarter, - fiscal_year, - forecast_category, - forecast_category_name, - has_open_activity, - has_opportunity_line_item, - has_overdue_task, + {{ coalesce_w_renamed_col('fiscal_quarter') }}, + {{ coalesce_w_renamed_col('fiscal_year') }}, + {{ coalesce_w_renamed_col('forecast_category') }}, + {{ coalesce_w_renamed_col('forecast_category_name') }}, + {{ coalesce_w_renamed_col('has_open_activity') }}, + {{ coalesce_w_renamed_col('has_opportunity_line_item') }}, + {{ coalesce_w_renamed_col('has_overdue_task') }}, id as opportunity_id, - is_closed, - is_deleted, - is_won, - cast(last_activity_date as {{ dbt.type_timestamp() }}) as last_activity_date, - cast(last_referenced_date as {{ dbt.type_timestamp() }}) as last_referenced_date, - cast(last_viewed_date as {{ dbt.type_timestamp() }}) as last_viewed_date, - lead_source, + {{ coalesce_w_renamed_col('is_closed') }}, + {{ coalesce_w_renamed_col('is_deleted') }}, + {{ coalesce_w_renamed_col('is_won') }}, + {{ coalesce_w_renamed_col('last_activity_date', datatype=dbt.type_timestamp()) }}, + {{ coalesce_w_renamed_col('last_referenced_date', datatype=dbt.type_timestamp()) }}, + {{ coalesce_w_renamed_col('last_viewed_date', datatype=dbt.type_timestamp()) }}, + {{ coalesce_w_renamed_col('lead_source') }}, name as opportunity_name, - next_step, - owner_id, + {{ coalesce_w_renamed_col('next_step') }}, + {{ coalesce_w_renamed_col('owner_id') }}, probability, - record_type_id, - stage_name, - synced_quote_id, + {{ coalesce_w_renamed_col('record_type_id') }}, + {{ coalesce_w_renamed_col('stage_name') }}, + {{ coalesce_w_renamed_col('synced_quote_id') }}, type {{ fivetran_utils.fill_pass_through_columns('salesforce__opportunity_pass_through_columns') }} diff --git a/models/salesforce/stg_salesforce__opportunity_line_item.sql b/models/salesforce/stg_salesforce__opportunity_line_item.sql index 10ce16e..2d945bc 100644 --- a/models/salesforce/stg_salesforce__opportunity_line_item.sql +++ b/models/salesforce/stg_salesforce__opportunity_line_item.sql @@ -19,29 +19,29 @@ final as ( select cast(_fivetran_synced as {{ dbt.type_timestamp() }}) as _fivetran_synced, id as opportunity_line_item_id, - created_by_id, - cast(created_date as {{ dbt.type_timestamp() }}) as created_date, + {{ coalesce_w_renamed_col('created_by_id') }}, + {{ coalesce_w_renamed_col('created_date', datatype=dbt.type_timestamp()) }}, description as opportunity_line_item_description, discount, - has_quantity_schedule, - has_revenue_schedule, - has_schedule, - is_deleted, - last_modified_by_id, - cast(last_modified_date as {{ dbt.type_timestamp() }}) as last_modified_date, - cast(last_referenced_date as {{ dbt.type_timestamp() }}) as last_referenced_date, - cast(last_viewed_date as {{ dbt.type_timestamp() }}) as last_viewed_date, - list_price, + {{ coalesce_w_renamed_col('has_quantity_schedule') }}, + {{ coalesce_w_renamed_col('has_revenue_schedule') }}, + {{ coalesce_w_renamed_col('has_schedule') }}, + {{ coalesce_w_renamed_col('is_deleted') }}, + {{ coalesce_w_renamed_col('last_modified_by_id') }}, + {{ coalesce_w_renamed_col('last_modified_date', datatype=dbt.type_timestamp()) }}, + {{ coalesce_w_renamed_col('last_referenced_date', datatype=dbt.type_timestamp()) }}, + {{ coalesce_w_renamed_col('last_viewed_date', datatype=dbt.type_timestamp()) }}, + {{ coalesce_w_renamed_col('list_price') }}, name as opportunity_line_item_name, - opportunity_id, - pricebook_entry_id, - product_2_id, - product_code, + {{ coalesce_w_renamed_col('opportunity_id') }}, + {{ coalesce_w_renamed_col('pricebook_entry_id') }}, + {{ coalesce_w_renamed_col('product_2_id') }}, + {{ coalesce_w_renamed_col('product_code') }}, quantity, - cast(service_date as {{ dbt.type_timestamp() }}) as service_date, - sort_order, - total_price, - unit_price + {{ coalesce_w_renamed_col('service_date', datatype=dbt.type_timestamp()) }}, + {{ coalesce_w_renamed_col('sort_order') }}, + {{ coalesce_w_renamed_col('total_price') }}, + {{ coalesce_w_renamed_col('unit_price') }} {{ fivetran_utils.fill_pass_through_columns('salesforce__opportunity_line_item_pass_through_columns') }} diff --git a/models/salesforce/stg_salesforce__order.sql b/models/salesforce/stg_salesforce__order.sql index 63564d0..f005afb 100644 --- a/models/salesforce/stg_salesforce__order.sql +++ b/models/salesforce/stg_salesforce__order.sql @@ -19,40 +19,40 @@ final as ( select cast(_fivetran_synced as {{ dbt.type_timestamp() }}) as _fivetran_synced, id as order_id, - account_id, - activated_by_id, - cast(activated_date as {{ dbt.type_timestamp() }}) as activated_date, - billing_city, - billing_country, - billing_country_code, - billing_postal_code, - billing_state, - billing_state_code, - billing_street, - contract_id, - created_by_id, - created_date, + {{ coalesce_w_renamed_col('account_id') }}, + {{ coalesce_w_renamed_col('activated_by_id') }}, + {{ coalesce_w_renamed_col('activated_date', datatype=dbt.type_timestamp()) }}, + {{ coalesce_w_renamed_col('billing_city') }}, + {{ coalesce_w_renamed_col('billing_country') }}, + {{ coalesce_w_renamed_col('billing_country_code') }}, + {{ coalesce_w_renamed_col('billing_postal_code') }}, + {{ coalesce_w_renamed_col('billing_state') }}, + {{ coalesce_w_renamed_col('billing_state_code') }}, + {{ coalesce_w_renamed_col('billing_street') }}, + {{ coalesce_w_renamed_col('contract_id') }}, + {{ coalesce_w_renamed_col('created_by_id') }}, + {{ coalesce_w_renamed_col('created_date') }}, description as order_description, - cast(end_date as {{ dbt.type_timestamp() }}) as end_date, - is_deleted, - last_modified_by_id, - cast(last_modified_date as {{ dbt.type_timestamp() }}) as last_modified_date, - cast(last_referenced_date as {{ dbt.type_timestamp() }}) as last_referenced_date, - cast(last_viewed_date as {{ dbt.type_timestamp() }}) as last_viewed_date, - opportunity_id, - order_number, - original_order_id, - owner_id, - pricebook_2_id, - shipping_city, - shipping_country, - shipping_country_code, - shipping_postal_code, - shipping_state, - shipping_state_code, - shipping_street, + {{ coalesce_w_renamed_col('end_date', datatype=dbt.type_timestamp()) }}, + {{ coalesce_w_renamed_col('is_deleted') }}, + {{ coalesce_w_renamed_col('last_modified_by_id') }}, + {{ coalesce_w_renamed_col('last_modified_date', datatype=dbt.type_timestamp()) }}, + {{ coalesce_w_renamed_col('last_referenced_date', datatype=dbt.type_timestamp()) }}, + {{ coalesce_w_renamed_col('last_viewed_date', datatype=dbt.type_timestamp()) }}, + {{ coalesce_w_renamed_col('opportunity_id') }}, + {{ coalesce_w_renamed_col('order_number') }}, + {{ coalesce_w_renamed_col('original_order_id') }}, + {{ coalesce_w_renamed_col('owner_id') }}, + {{ coalesce_w_renamed_col('pricebook_2_id') }}, + {{ coalesce_w_renamed_col('shipping_city') }}, + {{ coalesce_w_renamed_col('shipping_country') }}, + {{ coalesce_w_renamed_col('shipping_country_code') }}, + {{ coalesce_w_renamed_col('shipping_postal_code') }}, + {{ coalesce_w_renamed_col('shipping_state') }}, + {{ coalesce_w_renamed_col('shipping_state_code') }}, + {{ coalesce_w_renamed_col('shipping_street') }}, status, - total_amount, + {{ coalesce_w_renamed_col('total_amount') }}, type {{ fivetran_utils.fill_pass_through_columns('salesforce__order_pass_through_columns') }} diff --git a/models/salesforce/stg_salesforce__product_2.sql b/models/salesforce/stg_salesforce__product_2.sql index c99aa90..f69f048 100644 --- a/models/salesforce/stg_salesforce__product_2.sql +++ b/models/salesforce/stg_salesforce__product_2.sql @@ -19,29 +19,29 @@ final as ( select cast(_fivetran_synced as {{ dbt.type_timestamp() }}) as _fivetran_synced, id as product_2_id, - created_by_id, - cast(created_date as {{ dbt.type_timestamp() }}) as created_date, + {{ coalesce_w_renamed_col('created_by_id') }}, + {{ coalesce_w_renamed_col('created_date', datatype=dbt.type_timestamp()) }}, description as product_2_description, - display_url, - external_id, + {{ coalesce_w_renamed_col('display_url') }}, + {{ coalesce_w_renamed_col('external_id') }}, family, - is_active, - is_archived, - is_deleted, - last_modified_by_id, - cast(last_modified_date as {{ dbt.type_timestamp() }}) as last_modified_date, - cast(last_referenced_date as {{ dbt.type_timestamp() }}) as last_referenced_date, - cast(last_viewed_date as {{ dbt.type_timestamp() }}) as last_viewed_date, + {{ coalesce_w_renamed_col('is_active') }}, + {{ coalesce_w_renamed_col('is_archived') }}, + {{ coalesce_w_renamed_col('is_deleted') }}, + {{ coalesce_w_renamed_col('last_modified_by_id') }}, + {{ coalesce_w_renamed_col('last_modified_date', datatype=dbt.type_timestamp()) }}, + {{ coalesce_w_renamed_col('last_referenced_date', datatype=dbt.type_timestamp()) }}, + {{ coalesce_w_renamed_col('last_viewed_date', datatype=dbt.type_timestamp()) }}, name as product_2_name, - number_of_quantity_installments, - number_of_revenue_installments, - product_code, - quantity_installment_period, - quantity_schedule_type, - quantity_unit_of_measure, - record_type_id, - revenue_installment_period, - revenue_schedule_type + {{ coalesce_w_renamed_col('number_of_quantity_installments') }}, + {{ coalesce_w_renamed_col('number_of_revenue_installments') }}, + {{ coalesce_w_renamed_col('product_code') }}, + {{ coalesce_w_renamed_col('quantity_installment_period') }}, + {{ coalesce_w_renamed_col('quantity_schedule_type') }}, + {{ coalesce_w_renamed_col('quantity_unit_of_measure') }}, + {{ coalesce_w_renamed_col('record_type_id') }}, + {{ coalesce_w_renamed_col('revenue_installment_period') }}, + {{ coalesce_w_renamed_col('revenue_schedule_type') }} {{ fivetran_utils.fill_pass_through_columns('salesforce__product_2_pass_through_columns') }} diff --git a/models/salesforce/stg_salesforce__task.sql b/models/salesforce/stg_salesforce__task.sql index cf7654b..7fef701 100644 --- a/models/salesforce/stg_salesforce__task.sql +++ b/models/salesforce/stg_salesforce__task.sql @@ -19,33 +19,33 @@ final as ( select cast(_fivetran_synced as {{ dbt.type_timestamp() }}) as _fivetran_synced, id as task_id, - account_id, - cast(activity_date as {{ dbt.type_timestamp() }}) as activity_date, - call_disposition, - call_duration_in_seconds, - call_object, - call_type, - cast(completed_date_time as {{ dbt.type_timestamp() }}) as completed_date_time, - created_by_id, - cast(created_date as {{ dbt.type_timestamp() }}) as created_date, + {{ coalesce_w_renamed_col('account_id') }}, + {{ coalesce_w_renamed_col('activity_date', datatype=dbt.type_timestamp()) }}, + {{ coalesce_w_renamed_col('call_disposition') }}, + {{ coalesce_w_renamed_col('call_duration_in_seconds') }}, + {{ coalesce_w_renamed_col('call_object') }}, + {{ coalesce_w_renamed_col('call_type') }}, + {{ coalesce_w_renamed_col('completed_date_time', datatype=dbt.type_timestamp()) }}, + {{ coalesce_w_renamed_col('created_by_id') }}, + {{ coalesce_w_renamed_col('created_date', datatype=dbt.type_timestamp()) }}, description as task_description, - is_archived, - is_closed, - is_deleted, - is_high_priority, - last_modified_by_id, - cast(last_modified_date as {{ dbt.type_timestamp() }}) as last_modified_date, - owner_id, + {{ coalesce_w_renamed_col('is_archived') }}, + {{ coalesce_w_renamed_col('is_closed') }}, + {{ coalesce_w_renamed_col('is_deleted') }}, + {{ coalesce_w_renamed_col('is_high_priority') }}, + {{ coalesce_w_renamed_col('last_modified_by_id') }}, + {{ coalesce_w_renamed_col('last_modified_date', datatype=dbt.type_timestamp()) }}, + {{ coalesce_w_renamed_col('owner_id') }}, priority, - record_type_id, + {{ coalesce_w_renamed_col('record_type_id') }}, status, subject, - task_subtype, + {{ coalesce_w_renamed_col('task_subtype') }}, type, - what_count, - what_id, - who_count, - who_id + {{ coalesce_w_renamed_col('what_count') }}, + {{ coalesce_w_renamed_col('what_id') }}, + {{ coalesce_w_renamed_col('who_count') }}, + {{ coalesce_w_renamed_col('who_id') }} {{ fivetran_utils.fill_pass_through_columns('salesforce__task_pass_through_columns') }} diff --git a/models/salesforce/stg_salesforce__user.sql b/models/salesforce/stg_salesforce__user.sql index 6ea6346..d5a3fc3 100644 --- a/models/salesforce/stg_salesforce__user.sql +++ b/models/salesforce/stg_salesforce__user.sql @@ -18,33 +18,33 @@ final as ( select _fivetran_deleted, cast(_fivetran_synced as {{ dbt.type_timestamp() }}) as _fivetran_synced, - account_id, + {{ coalesce_w_renamed_col('account_id') }}, alias, city, - company_name, - contact_id, + {{ coalesce_w_renamed_col('company_name') }}, + {{ coalesce_w_renamed_col('contact_id') }}, country, - country_code, + {{ coalesce_w_renamed_col('country_code') }}, department, email, - first_name, + {{ coalesce_w_renamed_col('first_name') }}, id as user_id, - individual_id, - is_active, - cast(last_login_date as {{ dbt.type_timestamp() }}) as last_login_date, - last_name, - cast(last_referenced_date as {{ dbt.type_timestamp() }}) as last_referenced_date, - cast(last_viewed_date as {{ dbt.type_timestamp() }}) as last_viewed_date, - manager_id, + {{ coalesce_w_renamed_col('individual_id') }}, + {{ coalesce_w_renamed_col('is_active') }}, + {{ coalesce_w_renamed_col('last_login_date', datatype=dbt.type_timestamp()) }}, + {{ coalesce_w_renamed_col('last_name') }}, + {{ coalesce_w_renamed_col('last_referenced_date', datatype=dbt.type_timestamp()) }}, + {{ coalesce_w_renamed_col('last_viewed_date', datatype=dbt.type_timestamp()) }}, + {{ coalesce_w_renamed_col('manager_id') }}, name as user_name, - postal_code, - profile_id, + {{ coalesce_w_renamed_col('postal_code') }}, + {{ coalesce_w_renamed_col('profile_id') }}, state, - state_code, + {{ coalesce_w_renamed_col('state_code') }}, street, title, - user_role_id, - user_type, + {{ coalesce_w_renamed_col('user_role_id') }}, + {{ coalesce_w_renamed_col('user_type') }}, username {{ fivetran_utils.fill_pass_through_columns('salesforce__user_pass_through_columns') }} diff --git a/models/salesforce/stg_salesforce__user_role.sql b/models/salesforce/stg_salesforce__user_role.sql index ee4eaf6..4b31e52 100644 --- a/models/salesforce/stg_salesforce__user_role.sql +++ b/models/salesforce/stg_salesforce__user_role.sql @@ -20,12 +20,12 @@ final as ( select _fivetran_deleted, cast(_fivetran_synced as {{ dbt.type_timestamp() }}) as _fivetran_synced, - developer_name, + {{ coalesce_w_renamed_col('developer_name') }}, id as user_role_id, name as user_role_name, - opportunity_access_for_account_owner, - parent_role_id, - rollup_description + {{ coalesce_w_renamed_col('opportunity_access_for_account_owner') }}, + {{ coalesce_w_renamed_col('parent_role_id') }}, + {{ coalesce_w_renamed_col('rollup_description') }} {{ fivetran_utils.fill_pass_through_columns('salesforce__user_role_pass_through_columns') }} From 9b5db076e9d9d869db5150431dd2af20564f63bd Mon Sep 17 00:00:00 2001 From: fivetran-catfritz <111930712+fivetran-catfritz@users.noreply.github.com> Date: Fri, 28 Jun 2024 19:51:23 -0500 Subject: [PATCH 2/7] add macro file --- macros/coalesce_w_renamed_col.sql | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 macros/coalesce_w_renamed_col.sql diff --git a/macros/coalesce_w_renamed_col.sql b/macros/coalesce_w_renamed_col.sql new file mode 100644 index 0000000..88e106a --- /dev/null +++ b/macros/coalesce_w_renamed_col.sql @@ -0,0 +1,13 @@ +{% macro coalesce_w_renamed_col(original_column_name, datatype=none) %} + +{%- set renamed_col = original_column_name.replace('_', '') -%} + +{% if datatype is none -%} +coalesce({{ renamed_col }}, {{ original_column_name }}) +{% else -%} +coalesce(cast({{ renamed_col }} as {{ datatype }}), + cast({{ original_column_name }} as {{ datatype }})) +{% endif -%} +as {{ original_column_name }} + +{%- endmacro %} \ No newline at end of file From fb850fc589f8ace983426f089adf2f8ff86ac788 Mon Sep 17 00:00:00 2001 From: fivetran-catfritz <111930712+fivetran-catfritz@users.noreply.github.com> Date: Fri, 28 Jun 2024 21:34:56 -0500 Subject: [PATCH 3/7] add casting --- integration_tests/dbt_project.yml | 118 +++++++++++++++++++++++++++--- macros/coalesce_w_renamed_col.sql | 2 +- 2 files changed, 110 insertions(+), 10 deletions(-) diff --git a/integration_tests/dbt_project.yml b/integration_tests/dbt_project.yml index 848a163..a72b698 100644 --- a/integration_tests/dbt_project.yml +++ b/integration_tests/dbt_project.yml @@ -7,7 +7,7 @@ profile: 'integration_tests' vars: salesforce_source: - salesforce_schema: salesforce_source_integrations_tests_3 + salesforce_schema: zz_dbt_catherine_sf #salesforce_source_integrations_tests_3 salesforce_history_schema: salesforce_source_integrations_tests_3 salesforce_account_identifier: "sf_account_data" @@ -44,63 +44,125 @@ seeds: last_activity_date: timestamp last_referenced_date: timestamp last_viewed_date: timestamp + account_number: "{{ 'string' if target.name in ['bigquery','spark', 'databricks'] else 'varchar' }}" annual_revenue: float billing_latitude: float billing_longitude: float + parent_id: "{{ 'string' if target.name in ['bigquery','spark', 'databricks'] else 'varchar' }}" + product_code: "{{ 'string' if target.name in ['bigquery','spark', 'databricks'] else 'varchar' }}" + shipping_city: "{{ 'string' if target.name in ['bigquery','spark', 'databricks'] else 'varchar' }}" + shipping_country: "{{ 'string' if target.name in ['bigquery','spark', 'databricks'] else 'varchar' }}" + shipping_country_code: "{{ 'string' if target.name in ['bigquery','spark', 'databricks'] else 'varchar' }}" + shipping_postal_code: "{{ 'string' if target.name in ['bigquery','spark', 'databricks'] else 'varchar' }}" + shipping_state: "{{ 'string' if target.name in ['bigquery','spark', 'databricks'] else 'varchar' }}" + shipping_state_code: "{{ 'string' if target.name in ['bigquery','spark', 'databricks'] else 'varchar' }}" + shipping_street: "{{ 'string' if target.name in ['bigquery','spark', 'databricks'] else 'varchar' }}" shipping_latitude: float shipping_longitude: float sf_opportunity_data: +column_types: + amount: float + campaign_id: "{{ 'string' if target.name in ['bigquery','spark', 'databricks'] else 'varchar' }}" close_date: timestamp + converted_account_id: "{{ 'string' if target.name in ['bigquery','spark', 'databricks'] else 'varchar' }}" + converted_contact_id: "{{ 'string' if target.name in ['bigquery','spark', 'databricks'] else 'varchar' }}" + converted_opportunity_id: "{{ 'string' if target.name in ['bigquery','spark', 'databricks'] else 'varchar' }}" + created_by_id: "{{ 'string' if target.name in ['bigquery','spark', 'databricks'] else 'varchar' }}" created_date: timestamp + individual_id: "{{ 'string' if target.name in ['bigquery','spark', 'databricks'] else 'varchar' }}" last_activity_date: timestamp + last_modified_by_id: "{{ 'string' if target.name in ['bigquery','spark', 'databricks'] else 'varchar' }}" last_referenced_date: timestamp last_viewed_date: timestamp - amount: float + master_record_id: "{{ 'string' if target.name in ['bigquery','spark', 'databricks'] else 'varchar' }}" + mobile_phone: "{{ 'string' if target.name in ['bigquery','spark', 'databricks'] else 'varchar' }}" + next_step: "{{ 'string' if target.name in ['bigquery','spark', 'databricks'] else 'varchar' }}" + owner_id: "{{ 'string' if target.name in ['bigquery','spark', 'databricks'] else 'varchar' }}" + phone: "{{ 'string' if target.name in ['bigquery','spark', 'databricks'] else 'varchar' }}" + postal_code: "{{ 'string' if target.name in ['bigquery','spark', 'databricks'] else 'varchar' }}" probability: float + state_code: "{{ 'string' if target.name in ['bigquery','spark', 'databricks'] else 'varchar' }}" + synced_quote_id: "{{ 'string' if target.name in ['bigquery','spark', 'databricks'] else 'varchar' }}" sf_user_data: +column_types: + account_id: "{{ 'string' if target.name in ['bigquery','spark', 'databricks'] else 'varchar' }}" + company_name: "{{ 'string' if target.name in ['bigquery','spark', 'databricks'] else 'varchar' }}" + contact_id: "{{ 'string' if target.name in ['bigquery','spark', 'databricks'] else 'varchar' }}" + country_code: "{{ 'string' if target.name in ['bigquery','spark', 'databricks'] else 'varchar' }}" + individual_id: "{{ 'string' if target.name in ['bigquery','spark', 'databricks'] else 'varchar' }}" last_login_date: timestamp last_referenced_date: timestamp last_viewed_date: timestamp - offline_trial_expiration_date: timestamp latitude: float longitude: float + manager_id: "{{ 'string' if target.name in ['bigquery','spark', 'databricks'] else 'varchar' }}" + offline_trial_expiration_date: timestamp + postal_code: "{{ 'string' if target.name in ['bigquery','spark', 'databricks'] else 'varchar' }}" + profile_id: "{{ 'string' if target.name in ['bigquery','spark', 'databricks'] else 'varchar' }}" + state_code: "{{ 'string' if target.name in ['bigquery','spark', 'databricks'] else 'varchar' }}" + user_role_id: "{{ 'string' if target.name in ['bigquery','spark', 'databricks'] else 'varchar' }}" sf_contact_data: +column_types: birthdate: timestamp created_date: timestamp email_bounced_date: timestamp + home_phone: "{{ 'string' if target.name in ['bigquery','spark', 'databricks'] else 'varchar' }}" + individual_id: "{{ 'string' if target.name in ['bigquery','spark', 'databricks'] else 'varchar' }}" + is_deleted: boolean last_activity_date: timestamp last_curequest_date: timestamp last_cuupdate_date: timestamp last_modified_date: timestamp last_referenced_date: timestamp last_viewed_date: timestamp + mailing_postal_code: "{{ 'string' if target.name in ['bigquery','spark', 'databricks'] else 'varchar' }}" + master_record_id: "{{ 'string' if target.name in ['bigquery','spark', 'databricks'] else 'varchar' }}" + mobile_phone: "{{ 'string' if target.name in ['bigquery','spark', 'databricks'] else 'varchar' }}" + reports_to_id: "{{ 'string' if target.name in ['bigquery','spark', 'databricks'] else 'varchar' }}" system_modstamp: timestamp - is_deleted: boolean sf_lead_data: +column_types: converted_date: timestamp + converted_opportunity_id: "{{ 'string' if target.name in ['bigquery','spark', 'databricks'] else 'varchar' }}" + country_code: "{{ 'string' if target.name in ['bigquery','spark', 'databricks'] else 'varchar' }}" created_date: timestamp email_bounced_date: timestamp + email_bounced_reason: "{{ 'string' if target.name in ['bigquery','spark', 'databricks'] else 'varchar' }}" + individual_id: "{{ 'string' if target.name in ['bigquery','spark', 'databricks'] else 'varchar' }}" last_activity_date: timestamp last_modified_date: timestamp last_referenced_date: timestamp last_viewed_date: timestamp + lead_source: "{{ 'string' if target.name in ['bigquery','spark', 'databricks'] else 'varchar' }}" + master_record_id: "{{ 'string' if target.name in ['bigquery','spark', 'databricks'] else 'varchar' }}" + mobile_phone: "{{ 'string' if target.name in ['bigquery','spark', 'databricks'] else 'varchar' }}" + owner_id: "{{ 'string' if target.name in ['bigquery','spark', 'databricks'] else 'varchar' }}" + phone: "{{ 'string' if target.name in ['bigquery','spark', 'databricks'] else 'varchar' }}" + postal_code: "{{ 'string' if target.name in ['bigquery','spark', 'databricks'] else 'varchar' }}" + state_code: "{{ 'string' if target.name in ['bigquery','spark', 'databricks'] else 'varchar' }}" system_modstamp: timestamp is_deleted: boolean sf_task_data: +column_types: + account_id: "{{ 'string' if target.name in ['bigquery','spark', 'databricks'] else 'varchar' }}" activity_date: timestamp + call_disposition: "{{ 'string' if target.name in ['bigquery','spark', 'databricks'] else 'varchar' }}" + call_object: "{{ 'string' if target.name in ['bigquery','spark', 'databricks'] else 'varchar' }}" + call_type: "{{ 'string' if target.name in ['bigquery','spark', 'databricks'] else 'varchar' }}" completed_date_time: timestamp + created_by_id: "{{ 'string' if target.name in ['bigquery','spark', 'databricks'] else 'varchar' }}" created_date: timestamp + is_deleted: boolean + last_modified_by_id: "{{ 'string' if target.name in ['bigquery','spark', 'databricks'] else 'varchar' }}" last_modified_date: timestamp + owner_id: "{{ 'string' if target.name in ['bigquery','spark', 'databricks'] else 'varchar' }}" + record_type_id: "{{ 'string' if target.name in ['bigquery','spark', 'databricks'] else 'varchar' }}" recurrence_end_date_only: timestamp recurrence_start_date_only: timestamp reminder_date_time: timestamp system_modstamp: timestamp - is_deleted: boolean + what_id: "{{ 'string' if target.name in ['bigquery','spark', 'databricks'] else 'varchar' }}" + who_id: "{{ 'string' if target.name in ['bigquery','spark', 'databricks'] else 'varchar' }}" sf_event_data: +column_types: activity_date: timestamp @@ -108,6 +170,7 @@ seeds: created_date: timestamp end_date: timestamp end_date_time: timestamp + group_event_type: "{{ 'string' if target.name in ['bigquery','spark', 'databricks'] else 'varchar' }}" last_modified_date : timestamp recurrence_2_pattern_start_date : timestamp recurrence_end_date_only: timestamp @@ -118,32 +181,69 @@ seeds: is_deleted: boolean sf_product_2_data: +column_types: + created_by_id: "{{ 'string' if target.name in ['bigquery','spark', 'databricks'] else 'varchar' }}" created_date: timestamp + display_url: "{{ 'string' if target.name in ['bigquery','spark', 'databricks'] else 'varchar' }}" + external_id: "{{ 'string' if target.name in ['bigquery','spark', 'databricks'] else 'varchar' }}" + is_deleted: boolean + last_modified_by_id: "{{ 'string' if target.name in ['bigquery','spark', 'databricks'] else 'varchar' }}" last_modified_date: timestamp last_referenced_date: timestamp last_viewed_date: timestamp + product_code: "{{ 'string' if target.name in ['bigquery','spark', 'databricks'] else 'varchar' }}" + quantity_installment_period: "{{ 'string' if target.name in ['bigquery','spark', 'databricks'] else 'varchar' }}" + quantity_schedule_type: "{{ 'string' if target.name in ['bigquery','spark', 'databricks'] else 'varchar' }}" + quantity_unit_of_measure: "{{ 'string' if target.name in ['bigquery','spark', 'databricks'] else 'varchar' }}" + record_type_id: "{{ 'string' if target.name in ['bigquery','spark', 'databricks'] else 'varchar' }}" + revenue_installment_period: "{{ 'string' if target.name in ['bigquery','spark', 'databricks'] else 'varchar' }}" + revenue_schedule_type: "{{ 'string' if target.name in ['bigquery','spark', 'databricks'] else 'varchar' }}" system_modstamp: timestamp - is_deleted: boolean sf_order_data: +column_types: + account_id: "{{ 'string' if target.name in ['bigquery','spark', 'databricks'] else 'varchar' }}" + activated_by_id: "{{ 'string' if target.name in ['bigquery','spark', 'databricks'] else 'varchar' }}" activated_date: timestamp + billing_country_code: "{{ 'string' if target.name in ['bigquery','spark', 'databricks'] else 'varchar' }}" + billing_state_code: "{{ 'string' if target.name in ['bigquery','spark', 'databricks'] else 'varchar' }}" + contract_id: "{{ 'string' if target.name in ['bigquery','spark', 'databricks'] else 'varchar' }}" + created_by_id: "{{ 'string' if target.name in ['bigquery','spark', 'databricks'] else 'varchar' }}" created_date: timestamp effective_date: timestamp end_date: timestamp + is_deleted: boolean + last_modified_by_id: "{{ 'string' if target.name in ['bigquery','spark', 'databricks'] else 'varchar' }}" last_modified_date: timestamp last_referenced_date: timestamp last_viewed_date: timestamp + opportunity_id: "{{ 'string' if target.name in ['bigquery','spark', 'databricks'] else 'varchar' }}" + order_number: "{{ 'string' if target.name in ['bigquery','spark', 'databricks'] else 'varchar' }}" + original_order_id: "{{ 'string' if target.name in ['bigquery','spark', 'databricks'] else 'varchar' }}" + owner_id: "{{ 'string' if target.name in ['bigquery','spark', 'databricks'] else 'varchar' }}" + pricebook_2_id: "{{ 'string' if target.name in ['bigquery','spark', 'databricks'] else 'varchar' }}" + shipping_country_code: "{{ 'string' if target.name in ['bigquery','spark', 'databricks'] else 'varchar' }}" + shipping_postal_code: "{{ 'string' if target.name in ['bigquery','spark', 'databricks'] else 'varchar' }}" + shipping_state_code: "{{ 'string' if target.name in ['bigquery','spark', 'databricks'] else 'varchar' }}" system_modstamp: timestamp - is_deleted: boolean sf_opportunity_line_item_data: +column_types: + campaign_id: "{{ 'string' if target.name in ['bigquery','spark', 'databricks'] else 'varchar' }}" + created_by_id: "{{ 'string' if target.name in ['bigquery','spark', 'databricks'] else 'varchar' }}" created_date: timestamp + has_quantity_schedule: boolean + has_revenue_schedule: boolean + has_schedule: boolean + is_deleted: boolean + last_modified_by_id: "{{ 'string' if target.name in ['bigquery','spark', 'databricks'] else 'varchar' }}" last_modified_date: timestamp last_referenced_date: timestamp last_viewed_date: timestamp + opportunity_id: "{{ 'string' if target.name in ['bigquery','spark', 'databricks'] else 'varchar' }}" + product_2_id: "{{ 'string' if target.name in ['bigquery','spark', 'databricks'] else 'varchar' }}" service_date: timestamp system_modstamp: timestamp - is_deleted: boolean + sf_user_role_data: + +column_types: + parent_role_id: "{{ 'string' if target.name in ['bigquery','spark', 'databricks'] else 'varchar' }}" sf_account_history_data: +column_types: @@ -154,7 +254,7 @@ seeds: is_deleted: boolean sf_contact_history_data: +column_types: - birthdate: timestamp + birthdate: timestamp last_activity_date: timestamp last_modified_date: timestamp last_viewed_date: timestamp diff --git a/macros/coalesce_w_renamed_col.sql b/macros/coalesce_w_renamed_col.sql index 88e106a..4527ec3 100644 --- a/macros/coalesce_w_renamed_col.sql +++ b/macros/coalesce_w_renamed_col.sql @@ -1,5 +1,5 @@ {% macro coalesce_w_renamed_col(original_column_name, datatype=none) %} - +{# This macro accomodates Fivetran connectors that keep the original salesforce field naming conventions without underscores #} {%- set renamed_col = original_column_name.replace('_', '') -%} {% if datatype is none -%} From 0a0317b313d3b9e13b4ec2bcee59aa288ec6d4c5 Mon Sep 17 00:00:00 2001 From: fivetran-catfritz <111930712+fivetran-catfritz@users.noreply.github.com> Date: Fri, 28 Jun 2024 21:47:56 -0500 Subject: [PATCH 4/7] update yml --- integration_tests/dbt_project.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration_tests/dbt_project.yml b/integration_tests/dbt_project.yml index a72b698..8e9422d 100644 --- a/integration_tests/dbt_project.yml +++ b/integration_tests/dbt_project.yml @@ -7,7 +7,7 @@ profile: 'integration_tests' vars: salesforce_source: - salesforce_schema: zz_dbt_catherine_sf #salesforce_source_integrations_tests_3 + salesforce_schema: salesforce_source_integrations_tests_3 salesforce_history_schema: salesforce_source_integrations_tests_3 salesforce_account_identifier: "sf_account_data" From c012fd37b4a38fd96cf2ea7ed914c826d8323c57 Mon Sep 17 00:00:00 2001 From: fivetran-catfritz <111930712+fivetran-catfritz@users.noreply.github.com> Date: Mon, 1 Jul 2024 12:12:00 -0500 Subject: [PATCH 5/7] add casting for all --- macros/coalesce_w_renamed_col.sql | 9 +++---- macros/get_account_columns.sql | 6 ++--- macros/get_contact_columns.sql | 6 ++--- macros/get_event_columns.sql | 22 ++++++++-------- macros/get_lead_columns.sql | 18 ++++++------- macros/get_opportunity_columns.sql | 26 +++++++++---------- macros/get_opportunity_line_item_columns.sql | 18 ++++++------- macros/get_order_columns.sql | 6 ++--- macros/get_product_2_columns.sql | 14 +++++----- macros/get_task_columns.sql | 18 ++++++------- macros/get_user_columns.sql | 8 +++--- macros/get_user_role_columns.sql | 4 +-- models/salesforce/stg_salesforce__account.sql | 4 +-- models/salesforce/stg_salesforce__contact.sql | 4 +-- models/salesforce/stg_salesforce__event.sql | 14 +++++----- models/salesforce/stg_salesforce__lead.sql | 12 ++++----- .../stg_salesforce__opportunity.sql | 16 ++++++------ .../stg_salesforce__opportunity_line_item.sql | 16 ++++++------ models/salesforce/stg_salesforce__order.sql | 6 ++--- .../salesforce/stg_salesforce__product_2.sql | 10 +++---- models/salesforce/stg_salesforce__task.sql | 12 ++++----- models/salesforce/stg_salesforce__user.sql | 2 +- 22 files changed, 124 insertions(+), 127 deletions(-) diff --git a/macros/coalesce_w_renamed_col.sql b/macros/coalesce_w_renamed_col.sql index 4527ec3..4fec8f4 100644 --- a/macros/coalesce_w_renamed_col.sql +++ b/macros/coalesce_w_renamed_col.sql @@ -1,13 +1,10 @@ -{% macro coalesce_w_renamed_col(original_column_name, datatype=none) %} +{% macro coalesce_w_renamed_col(original_column_name, datatype=dbt.type_string()) %} {# This macro accomodates Fivetran connectors that keep the original salesforce field naming conventions without underscores #} + {%- set renamed_col = original_column_name.replace('_', '') -%} -{% if datatype is none -%} -coalesce({{ renamed_col }}, {{ original_column_name }}) -{% else -%} coalesce(cast({{ renamed_col }} as {{ datatype }}), cast({{ original_column_name }} as {{ datatype }})) -{% endif -%} -as {{ original_column_name }} + as {{ original_column_name }} {%- endmacro %} \ No newline at end of file diff --git a/macros/get_account_columns.sql b/macros/get_account_columns.sql index 7ad93c5..ae1764f 100644 --- a/macros/get_account_columns.sql +++ b/macros/get_account_columns.sql @@ -3,7 +3,7 @@ {% set columns = [ {"name": "_fivetran_synced", "datatype": dbt.type_timestamp()}, - {"name": "_fivetran_active", "datatype": "boolean"}, + {"name": "_fivetran_active", "datatype": dbt.type_boolean()}, {"name": "account_number", "datatype": dbt.type_string()}, {"name": "accountnumber", "datatype": dbt.type_string()}, {"name": "account_source", "datatype": dbt.type_string()}, @@ -25,8 +25,8 @@ {"name": "description", "datatype": dbt.type_string()}, {"name": "id", "datatype": dbt.type_string()}, {"name": "industry", "datatype": dbt.type_string()}, - {"name": "is_deleted", "datatype": "boolean"}, - {"name": "isdeleted", "datatype": "boolean"}, + {"name": "is_deleted", "datatype": dbt.type_boolean()}, + {"name": "isdeleted", "datatype": dbt.type_boolean()}, {"name": "last_activity_date", "datatype": dbt.type_timestamp()}, {"name": "lastactivitydate", "datatype": dbt.type_timestamp()}, {"name": "last_referenced_date", "datatype": dbt.type_timestamp()}, diff --git a/macros/get_contact_columns.sql b/macros/get_contact_columns.sql index b4f9767..cebc3df 100644 --- a/macros/get_contact_columns.sql +++ b/macros/get_contact_columns.sql @@ -2,7 +2,7 @@ {% set columns = [ {"name": "_fivetran_synced", "datatype": dbt.type_timestamp()}, - {"name": "_fivetran_active", "datatype": "boolean"}, + {"name": "_fivetran_active", "datatype": dbt.type_boolean()}, {"name": "account_id", "datatype": dbt.type_string()}, {"name": "accountid", "datatype": dbt.type_string()}, {"name": "department", "datatype": dbt.type_string()}, @@ -15,8 +15,8 @@ {"name": "id", "datatype": dbt.type_string()}, {"name": "individual_id", "datatype": dbt.type_string()}, {"name": "individualid", "datatype": dbt.type_string()}, - {"name": "is_deleted", "datatype": "boolean"}, - {"name": "isdeleted", "datatype": "boolean"}, + {"name": "is_deleted", "datatype": dbt.type_boolean()}, + {"name": "isdeleted", "datatype": dbt.type_boolean()}, {"name": "last_activity_date", "datatype": dbt.type_timestamp()}, {"name": "lastactivitydate", "datatype": dbt.type_timestamp()}, {"name": "last_modified_by_id", "datatype": dbt.type_string()}, diff --git a/macros/get_event_columns.sql b/macros/get_event_columns.sql index 843db2a..b809b4e 100644 --- a/macros/get_event_columns.sql +++ b/macros/get_event_columns.sql @@ -2,7 +2,7 @@ {% set columns = [ {"name": "_fivetran_synced", "datatype": dbt.type_timestamp()}, - {"name": "_fivetran_active", "datatype": "boolean"}, + {"name": "_fivetran_active", "datatype": dbt.type_boolean()}, {"name": "account_id", "datatype": dbt.type_string()}, {"name": "accountid", "datatype": dbt.type_string()}, {"name": "activity_date", "datatype": dbt.type_timestamp()}, @@ -23,16 +23,16 @@ {"name": "group_event_type", "datatype": dbt.type_string()}, {"name": "groupeventtype", "datatype": dbt.type_string()}, {"name": "id", "datatype": dbt.type_string()}, - {"name": "is_archived", "datatype": "boolean"}, - {"name": "isarchived", "datatype": "boolean"}, - {"name": "is_child", "datatype": "boolean"}, - {"name": "ischild", "datatype": "boolean"}, - {"name": "is_deleted", "datatype": "boolean"}, - {"name": "isdeleted", "datatype": "boolean"}, - {"name": "is_group_event", "datatype": "boolean"}, - {"name": "isgroupevent", "datatype": "boolean"}, - {"name": "is_recurrence", "datatype": "boolean"}, - {"name": "isrecurrence", "datatype": "boolean"}, + {"name": "is_archived", "datatype": dbt.type_boolean()}, + {"name": "isarchived", "datatype": dbt.type_boolean()}, + {"name": "is_child", "datatype": dbt.type_boolean()}, + {"name": "ischild", "datatype": dbt.type_boolean()}, + {"name": "is_deleted", "datatype": dbt.type_boolean()}, + {"name": "isdeleted", "datatype": dbt.type_boolean()}, + {"name": "is_group_event", "datatype": dbt.type_boolean()}, + {"name": "isgroupevent", "datatype": dbt.type_boolean()}, + {"name": "is_recurrence", "datatype": dbt.type_boolean()}, + {"name": "isrecurrence", "datatype": dbt.type_boolean()}, {"name": "last_modified_by_id", "datatype": dbt.type_string()}, {"name": "lastmodifiedbyid", "datatype": dbt.type_string()}, {"name": "last_modified_date", "datatype": dbt.type_timestamp()}, diff --git a/macros/get_lead_columns.sql b/macros/get_lead_columns.sql index b04d25f..3de0c02 100644 --- a/macros/get_lead_columns.sql +++ b/macros/get_lead_columns.sql @@ -2,7 +2,7 @@ {% set columns = [ {"name": "_fivetran_synced", "datatype": dbt.type_timestamp()}, - {"name": "_fivetran_active", "datatype": "boolean"}, + {"name": "_fivetran_active", "datatype": dbt.type_boolean()}, {"name": "annual_revenue", "datatype": dbt.type_float()}, {"name": "annualrevenue", "datatype": dbt.type_float()}, {"name": "city", "datatype": dbt.type_string()}, @@ -30,18 +30,18 @@ {"name": "emailbouncedreason", "datatype": dbt.type_string()}, {"name": "first_name", "datatype": dbt.type_string()}, {"name": "firstname", "datatype": dbt.type_string()}, - {"name": "has_opted_out_of_email", "datatype": "boolean"}, - {"name": "hasoptedoutofemail", "datatype": "boolean"}, + {"name": "has_opted_out_of_email", "datatype": dbt.type_boolean()}, + {"name": "hasoptedoutofemail", "datatype": dbt.type_boolean()}, {"name": "id", "datatype": dbt.type_string()}, {"name": "individual_id", "datatype": dbt.type_string()}, {"name": "individualid", "datatype": dbt.type_string()}, {"name": "industry", "datatype": dbt.type_string()}, - {"name": "is_converted", "datatype": "boolean"}, - {"name": "isconverted", "datatype": "boolean"}, - {"name": "is_deleted", "datatype": "boolean"}, - {"name": "isdeleted", "datatype": "boolean"}, - {"name": "is_unread_by_owner", "datatype": "boolean"}, - {"name": "isunreadbyowner", "datatype": "boolean"}, + {"name": "is_converted", "datatype": dbt.type_boolean()}, + {"name": "isconverted", "datatype": dbt.type_boolean()}, + {"name": "is_deleted", "datatype": dbt.type_boolean()}, + {"name": "isdeleted", "datatype": dbt.type_boolean()}, + {"name": "is_unread_by_owner", "datatype": dbt.type_boolean()}, + {"name": "isunreadbyowner", "datatype": dbt.type_boolean()}, {"name": "last_activity_date", "datatype": dbt.type_timestamp()}, {"name": "lastactivitydate", "datatype": dbt.type_timestamp()}, {"name": "last_modified_by_id", "datatype": dbt.type_string()}, diff --git a/macros/get_opportunity_columns.sql b/macros/get_opportunity_columns.sql index d4c47db..aa51a3d 100644 --- a/macros/get_opportunity_columns.sql +++ b/macros/get_opportunity_columns.sql @@ -3,7 +3,7 @@ {% set columns = [ {"name": "_fivetran_synced", "datatype": dbt.type_timestamp()}, - {"name": "_fivetran_active", "datatype": "boolean"}, + {"name": "_fivetran_active", "datatype": dbt.type_boolean()}, {"name": "account_id", "datatype": dbt.type_string()}, {"name": "accountid", "datatype": dbt.type_string()}, {"name": "amount", "datatype": dbt.type_float()}, @@ -25,19 +25,19 @@ {"name": "forecastcategory", "datatype": dbt.type_string()}, {"name": "forecast_category_name", "datatype": dbt.type_string()}, {"name": "forecastcategoryname", "datatype": dbt.type_string()}, - {"name": "has_open_activity", "datatype": "boolean"}, - {"name": "hasopenactivity", "datatype": "boolean"}, - {"name": "has_opportunity_line_item", "datatype": "boolean"}, - {"name": "hasopportunitylineitem", "datatype": "boolean"}, - {"name": "has_overdue_task", "datatype": "boolean"}, - {"name": "hasoverduetask", "datatype": "boolean"}, + {"name": "has_open_activity", "datatype": dbt.type_boolean()}, + {"name": "hasopenactivity", "datatype": dbt.type_boolean()}, + {"name": "has_opportunity_line_item", "datatype": dbt.type_boolean()}, + {"name": "hasopportunitylineitem", "datatype": dbt.type_boolean()}, + {"name": "has_overdue_task", "datatype": dbt.type_boolean()}, + {"name": "hasoverduetask", "datatype": dbt.type_boolean()}, {"name": "id", "datatype": dbt.type_string()}, - {"name": "is_closed", "datatype": "boolean"}, - {"name": "isclosed", "datatype": "boolean"}, - {"name": "is_deleted", "datatype": "boolean"}, - {"name": "isdeleted", "datatype": "boolean"}, - {"name": "is_won", "datatype": "boolean"}, - {"name": "iswon", "datatype": "boolean"}, + {"name": "is_closed", "datatype": dbt.type_boolean()}, + {"name": "isclosed", "datatype": dbt.type_boolean()}, + {"name": "is_deleted", "datatype": dbt.type_boolean()}, + {"name": "isdeleted", "datatype": dbt.type_boolean()}, + {"name": "is_won", "datatype": dbt.type_boolean()}, + {"name": "iswon", "datatype": dbt.type_boolean()}, {"name": "last_activity_date", "datatype": dbt.type_timestamp()}, {"name": "lastactivitydate", "datatype": dbt.type_timestamp()}, {"name": "last_referenced_date", "datatype": dbt.type_timestamp()}, diff --git a/macros/get_opportunity_line_item_columns.sql b/macros/get_opportunity_line_item_columns.sql index 0360d6c..e42dd3e 100644 --- a/macros/get_opportunity_line_item_columns.sql +++ b/macros/get_opportunity_line_item_columns.sql @@ -2,22 +2,22 @@ {% set columns = [ {"name": "_fivetran_synced", "datatype": dbt.type_timestamp()}, - {"name": "_fivetran_active", "datatype": "boolean"}, + {"name": "_fivetran_active", "datatype": dbt.type_boolean()}, {"name": "created_by_id", "datatype": dbt.type_string()}, {"name": "createdbyid", "datatype": dbt.type_string()}, {"name": "created_date", "datatype": dbt.type_timestamp()}, {"name": "createddate", "datatype": dbt.type_timestamp()}, {"name": "description", "datatype": dbt.type_string()}, {"name": "discount", "datatype": dbt.type_float()}, - {"name": "has_quantity_schedule", "datatype": "boolean"}, - {"name": "hasquantityschedule", "datatype": "boolean"}, - {"name": "has_revenue_schedule", "datatype": "boolean"}, - {"name": "hasrevenueschedule", "datatype": "boolean"}, - {"name": "has_schedule", "datatype": "boolean"}, - {"name": "hasschedule", "datatype": "boolean"}, + {"name": "has_quantity_schedule", "datatype": dbt.type_boolean()}, + {"name": "hasquantityschedule", "datatype": dbt.type_boolean()}, + {"name": "has_revenue_schedule", "datatype": dbt.type_boolean()}, + {"name": "hasrevenueschedule", "datatype": dbt.type_boolean()}, + {"name": "has_schedule", "datatype": dbt.type_boolean()}, + {"name": "hasschedule", "datatype": dbt.type_boolean()}, {"name": "id", "datatype": dbt.type_string()}, - {"name": "is_deleted", "datatype": "boolean"}, - {"name": "isdeleted", "datatype": "boolean"}, + {"name": "is_deleted", "datatype": dbt.type_boolean()}, + {"name": "isdeleted", "datatype": dbt.type_boolean()}, {"name": "last_modified_by_id", "datatype": dbt.type_string()}, {"name": "lastmodifiedbyid", "datatype": dbt.type_string()}, {"name": "last_modified_date", "datatype": dbt.type_timestamp()}, diff --git a/macros/get_order_columns.sql b/macros/get_order_columns.sql index 86559c0..39d3d16 100644 --- a/macros/get_order_columns.sql +++ b/macros/get_order_columns.sql @@ -2,7 +2,7 @@ {% set columns = [ {"name": "_fivetran_synced", "datatype": dbt.type_timestamp()}, - {"name": "_fivetran_active", "datatype": "boolean"}, + {"name": "_fivetran_active", "datatype": dbt.type_boolean()}, {"name": "account_id", "datatype": dbt.type_string()}, {"name": "accountid", "datatype": dbt.type_string()}, {"name": "activated_by_id", "datatype": dbt.type_string()}, @@ -33,8 +33,8 @@ {"name": "end_date", "datatype": dbt.type_timestamp()}, {"name": "enddate", "datatype": dbt.type_timestamp()}, {"name": "id", "datatype": dbt.type_string()}, - {"name": "is_deleted", "datatype": "boolean"}, - {"name": "isdeleted", "datatype": "boolean"}, + {"name": "is_deleted", "datatype": dbt.type_boolean()}, + {"name": "isdeleted", "datatype": dbt.type_boolean()}, {"name": "last_modified_by_id", "datatype": dbt.type_string()}, {"name": "lastmodifiedbyid", "datatype": dbt.type_string()}, {"name": "last_modified_date", "datatype": dbt.type_timestamp()}, diff --git a/macros/get_product_2_columns.sql b/macros/get_product_2_columns.sql index 9f2c223..fda435f 100644 --- a/macros/get_product_2_columns.sql +++ b/macros/get_product_2_columns.sql @@ -2,7 +2,7 @@ {% set columns = [ {"name": "_fivetran_synced", "datatype": dbt.type_timestamp()}, - {"name": "_fivetran_active", "datatype": "boolean"}, + {"name": "_fivetran_active", "datatype": dbt.type_boolean()}, {"name": "created_by_id", "datatype": dbt.type_string()}, {"name": "createdbyid", "datatype": dbt.type_string()}, {"name": "created_date", "datatype": dbt.type_timestamp()}, @@ -14,12 +14,12 @@ {"name": "externalid", "datatype": dbt.type_string()}, {"name": "family", "datatype": dbt.type_string()}, {"name": "id", "datatype": dbt.type_string()}, - {"name": "is_active", "datatype": "boolean"}, - {"name": "isactive", "datatype": "boolean"}, - {"name": "is_archived", "datatype": "boolean"}, - {"name": "isarchived", "datatype": "boolean"}, - {"name": "is_deleted", "datatype": "boolean"}, - {"name": "isdeleted", "datatype": "boolean"}, + {"name": "is_active", "datatype": dbt.type_boolean()}, + {"name": "isactive", "datatype": dbt.type_boolean()}, + {"name": "is_archived", "datatype": dbt.type_boolean()}, + {"name": "isarchived", "datatype": dbt.type_boolean()}, + {"name": "is_deleted", "datatype": dbt.type_boolean()}, + {"name": "isdeleted", "datatype": dbt.type_boolean()}, {"name": "last_modified_by_id", "datatype": dbt.type_string()}, {"name": "lastmodifiedbyid", "datatype": dbt.type_string()}, {"name": "last_modified_date", "datatype": dbt.type_timestamp()}, diff --git a/macros/get_task_columns.sql b/macros/get_task_columns.sql index 802451d..d2666a7 100644 --- a/macros/get_task_columns.sql +++ b/macros/get_task_columns.sql @@ -2,7 +2,7 @@ {% set columns = [ {"name": "_fivetran_synced", "datatype": dbt.type_timestamp()}, - {"name": "_fivetran_active", "datatype": "boolean"}, + {"name": "_fivetran_active", "datatype": dbt.type_boolean()}, {"name": "account_id", "datatype": dbt.type_string()}, {"name": "accountid", "datatype": dbt.type_string()}, {"name": "activity_date", "datatype": dbt.type_timestamp()}, @@ -23,14 +23,14 @@ {"name": "createddate", "datatype": dbt.type_timestamp()}, {"name": "description", "datatype": dbt.type_string()}, {"name": "id", "datatype": dbt.type_string()}, - {"name": "is_archived", "datatype": "boolean"}, - {"name": "isarchived", "datatype": "boolean"}, - {"name": "is_closed", "datatype": "boolean"}, - {"name": "isclosed", "datatype": "boolean"}, - {"name": "is_deleted", "datatype": "boolean"}, - {"name": "isdeleted", "datatype": "boolean"}, - {"name": "is_high_priority", "datatype": "boolean"}, - {"name": "ishighpriority", "datatype": "boolean"}, + {"name": "is_archived", "datatype": dbt.type_boolean()}, + {"name": "isarchived", "datatype": dbt.type_boolean()}, + {"name": "is_closed", "datatype": dbt.type_boolean()}, + {"name": "isclosed", "datatype": dbt.type_boolean()}, + {"name": "is_deleted", "datatype": dbt.type_boolean()}, + {"name": "isdeleted", "datatype": dbt.type_boolean()}, + {"name": "is_high_priority", "datatype": dbt.type_boolean()}, + {"name": "ishighpriority", "datatype": dbt.type_boolean()}, {"name": "last_modified_by_id", "datatype": dbt.type_string()}, {"name": "lastmodifiedbyid", "datatype": dbt.type_string()}, {"name": "last_modified_date", "datatype": dbt.type_timestamp()}, diff --git a/macros/get_user_columns.sql b/macros/get_user_columns.sql index 4062aec..ab99b7a 100644 --- a/macros/get_user_columns.sql +++ b/macros/get_user_columns.sql @@ -1,8 +1,8 @@ {% macro get_user_columns() %} {% set columns = [ - {"name": "_fivetran_deleted", "datatype": "boolean"}, - {"name": "_fivetran_active", "datatype": "boolean"}, + {"name": "_fivetran_deleted", "datatype": dbt.type_boolean()}, + {"name": "_fivetran_active", "datatype": dbt.type_boolean()}, {"name": "_fivetran_synced", "datatype": dbt.type_timestamp()}, {"name": "account_id", "datatype": dbt.type_string()}, {"name": "accountid", "datatype": dbt.type_string()}, @@ -22,8 +22,8 @@ {"name": "id", "datatype": dbt.type_string()}, {"name": "individual_id", "datatype": dbt.type_string()}, {"name": "individualid", "datatype": dbt.type_string()}, - {"name": "is_active", "datatype": "boolean"}, - {"name": "isactive", "datatype": "boolean"}, + {"name": "is_active", "datatype": dbt.type_boolean()}, + {"name": "isactive", "datatype": dbt.type_boolean()}, {"name": "last_login_date", "datatype": dbt.type_timestamp()}, {"name": "lastlogindate", "datatype": dbt.type_timestamp()}, {"name": "last_name", "datatype": dbt.type_string()}, diff --git a/macros/get_user_role_columns.sql b/macros/get_user_role_columns.sql index f483b86..e392538 100644 --- a/macros/get_user_role_columns.sql +++ b/macros/get_user_role_columns.sql @@ -1,8 +1,8 @@ {% macro get_user_role_columns() %} {% set columns = [ - {"name": "_fivetran_deleted", "datatype": "boolean"}, - {"name": "_fivetran_active", "datatype": "boolean"}, + {"name": "_fivetran_deleted", "datatype": dbt.type_boolean()}, + {"name": "_fivetran_active", "datatype": dbt.type_boolean()}, {"name": "_fivetran_synced", "datatype": dbt.type_timestamp()}, {"name": "developer_name", "datatype": dbt.type_string()}, {"name": "developername", "datatype": dbt.type_string()}, diff --git a/models/salesforce/stg_salesforce__account.sql b/models/salesforce/stg_salesforce__account.sql index dc47bd8..ad3eec9 100644 --- a/models/salesforce/stg_salesforce__account.sql +++ b/models/salesforce/stg_salesforce__account.sql @@ -28,13 +28,13 @@ final as ( description as account_description, id as account_id, industry, - {{ coalesce_w_renamed_col('is_deleted') }}, + {{ coalesce_w_renamed_col('is_deleted', datatype=dbt.type_boolean()) }}, {{ coalesce_w_renamed_col('last_activity_date', datatype=dbt.type_timestamp()) }}, {{ coalesce_w_renamed_col('last_referenced_date', datatype=dbt.type_timestamp()) }}, {{ coalesce_w_renamed_col('last_viewed_date', datatype=dbt.type_timestamp()) }}, {{ coalesce_w_renamed_col('master_record_id') }}, name as account_name, - {{ coalesce_w_renamed_col('number_of_employees') }}, + {{ coalesce_w_renamed_col('number_of_employees', datatype=dbt.type_int()) }}, {{ coalesce_w_renamed_col('owner_id') }}, ownership, {{ coalesce_w_renamed_col('parent_id') }}, diff --git a/models/salesforce/stg_salesforce__contact.sql b/models/salesforce/stg_salesforce__contact.sql index 6516a1d..e710e32 100644 --- a/models/salesforce/stg_salesforce__contact.sql +++ b/models/salesforce/stg_salesforce__contact.sql @@ -24,10 +24,10 @@ final as ( {{ coalesce_w_renamed_col('first_name') }}, {{ coalesce_w_renamed_col('home_phone') }}, {{ coalesce_w_renamed_col('individual_id') }}, - {{ coalesce_w_renamed_col('is_deleted') }}, + {{ coalesce_w_renamed_col('is_deleted', datatype=dbt.type_boolean()) }}, {{ coalesce_w_renamed_col('last_activity_date', datatype=dbt.type_timestamp()) }}, {{ coalesce_w_renamed_col('last_modified_by_id') }}, - {{ coalesce_w_renamed_col('last_modified_date') }}, + {{ coalesce_w_renamed_col('last_modified_date', datatype=dbt.type_timestamp()) }}, {{ coalesce_w_renamed_col('last_name') }}, {{ coalesce_w_renamed_col('last_referenced_date') }}, {{ coalesce_w_renamed_col('last_viewed_date', datatype=dbt.type_timestamp()) }}, diff --git a/models/salesforce/stg_salesforce__event.sql b/models/salesforce/stg_salesforce__event.sql index cf49f3b..a9e1065 100644 --- a/models/salesforce/stg_salesforce__event.sql +++ b/models/salesforce/stg_salesforce__event.sql @@ -29,11 +29,11 @@ final as ( {{ coalesce_w_renamed_col('end_date_time', datatype=dbt.type_timestamp()) }}, {{ coalesce_w_renamed_col('event_subtype') }}, {{ coalesce_w_renamed_col('group_event_type') }}, - {{ coalesce_w_renamed_col('is_archived') }}, - {{ coalesce_w_renamed_col('is_child') }}, - {{ coalesce_w_renamed_col('is_deleted') }}, - {{ coalesce_w_renamed_col('is_group_event') }}, - {{ coalesce_w_renamed_col('is_recurrence') }}, + {{ coalesce_w_renamed_col('is_archived', datatype=dbt.type_boolean()) }}, + {{ coalesce_w_renamed_col('is_child', datatype=dbt.type_boolean()) }}, + {{ coalesce_w_renamed_col('is_deleted', datatype=dbt.type_boolean()) }}, + {{ coalesce_w_renamed_col('is_group_event', datatype=dbt.type_boolean()) }}, + {{ coalesce_w_renamed_col('is_recurrence', datatype=dbt.type_boolean()) }}, {{ coalesce_w_renamed_col('last_modified_by_id') }}, {{ coalesce_w_renamed_col('last_modified_date', datatype=dbt.type_timestamp()) }}, location, @@ -41,9 +41,9 @@ final as ( {{ coalesce_w_renamed_col('start_date_time', datatype=dbt.type_timestamp()) }}, subject, type, - {{ coalesce_w_renamed_col('what_count') }}, + {{ coalesce_w_renamed_col('what_count', datatype=dbt.type_int()) }}, {{ coalesce_w_renamed_col('what_id') }}, - {{ coalesce_w_renamed_col('who_count') }}, + {{ coalesce_w_renamed_col('who_count', datatype=dbt.type_int()) }}, {{ coalesce_w_renamed_col('who_id') }} {{ fivetran_utils.fill_pass_through_columns('salesforce__event_pass_through_columns') }} diff --git a/models/salesforce/stg_salesforce__lead.sql b/models/salesforce/stg_salesforce__lead.sql index 1b3cf10..1275fd2 100644 --- a/models/salesforce/stg_salesforce__lead.sql +++ b/models/salesforce/stg_salesforce__lead.sql @@ -19,7 +19,7 @@ final as ( select cast(_fivetran_synced as {{ dbt.type_timestamp() }}) as _fivetran_synced, id as lead_id, - {{ coalesce_w_renamed_col('annual_revenue') }}, + {{ coalesce_w_renamed_col('annual_revenue', datatype=dbt.type_float()) }}, city, company, {{ coalesce_w_renamed_col('converted_account_id') }}, @@ -35,12 +35,12 @@ final as ( {{ coalesce_w_renamed_col('email_bounced_date', datatype=dbt.type_timestamp()) }}, {{ coalesce_w_renamed_col('email_bounced_reason') }}, {{ coalesce_w_renamed_col('first_name') }}, - {{ coalesce_w_renamed_col('has_opted_out_of_email') }}, + {{ coalesce_w_renamed_col('has_opted_out_of_email', datatype=dbt.type_boolean()) }}, {{ coalesce_w_renamed_col('individual_id') }}, industry, - {{ coalesce_w_renamed_col('is_converted') }}, - {{ coalesce_w_renamed_col('is_deleted') }}, - {{ coalesce_w_renamed_col('is_unread_by_owner') }}, + {{ coalesce_w_renamed_col('is_converted', datatype=dbt.type_boolean()) }}, + {{ coalesce_w_renamed_col('is_deleted', datatype=dbt.type_boolean()) }}, + {{ coalesce_w_renamed_col('is_unread_by_owner', datatype=dbt.type_boolean()) }}, {{ coalesce_w_renamed_col('last_activity_date', datatype=dbt.type_timestamp()) }}, {{ coalesce_w_renamed_col('last_modified_by_id') }}, {{ coalesce_w_renamed_col('last_modified_date', datatype=dbt.type_timestamp()) }}, @@ -51,7 +51,7 @@ final as ( {{ coalesce_w_renamed_col('master_record_id') }}, {{ coalesce_w_renamed_col('mobile_phone') }}, name as lead_name, - {{ coalesce_w_renamed_col('number_of_employees') }}, + {{ coalesce_w_renamed_col('number_of_employees', datatype=dbt.type_int()) }}, {{ coalesce_w_renamed_col('owner_id') }}, phone, {{ coalesce_w_renamed_col('postal_code') }}, diff --git a/models/salesforce/stg_salesforce__opportunity.sql b/models/salesforce/stg_salesforce__opportunity.sql index d28f2dd..4f50535 100644 --- a/models/salesforce/stg_salesforce__opportunity.sql +++ b/models/salesforce/stg_salesforce__opportunity.sql @@ -24,17 +24,17 @@ final as ( description as opportunity_description, {{ coalesce_w_renamed_col('expected_revenue', datatype=dbt.type_numeric()) }}, fiscal, - {{ coalesce_w_renamed_col('fiscal_quarter') }}, - {{ coalesce_w_renamed_col('fiscal_year') }}, + {{ coalesce_w_renamed_col('fiscal_quarter', datatype=dbt.type_int()) }}, + {{ coalesce_w_renamed_col('fiscal_year', datatype=dbt.type_int()) }}, {{ coalesce_w_renamed_col('forecast_category') }}, {{ coalesce_w_renamed_col('forecast_category_name') }}, - {{ coalesce_w_renamed_col('has_open_activity') }}, - {{ coalesce_w_renamed_col('has_opportunity_line_item') }}, - {{ coalesce_w_renamed_col('has_overdue_task') }}, + {{ coalesce_w_renamed_col('has_open_activity', datatype=dbt.type_boolean()) }}, + {{ coalesce_w_renamed_col('has_opportunity_line_item', datatype=dbt.type_boolean()) }}, + {{ coalesce_w_renamed_col('has_overdue_task', datatype=dbt.type_boolean()) }}, id as opportunity_id, - {{ coalesce_w_renamed_col('is_closed') }}, - {{ coalesce_w_renamed_col('is_deleted') }}, - {{ coalesce_w_renamed_col('is_won') }}, + {{ coalesce_w_renamed_col('is_closed', datatype=dbt.type_boolean()) }}, + {{ coalesce_w_renamed_col('is_deleted', datatype=dbt.type_boolean()) }}, + {{ coalesce_w_renamed_col('is_won', datatype=dbt.type_boolean()) }}, {{ coalesce_w_renamed_col('last_activity_date', datatype=dbt.type_timestamp()) }}, {{ coalesce_w_renamed_col('last_referenced_date', datatype=dbt.type_timestamp()) }}, {{ coalesce_w_renamed_col('last_viewed_date', datatype=dbt.type_timestamp()) }}, diff --git a/models/salesforce/stg_salesforce__opportunity_line_item.sql b/models/salesforce/stg_salesforce__opportunity_line_item.sql index 2d945bc..351f242 100644 --- a/models/salesforce/stg_salesforce__opportunity_line_item.sql +++ b/models/salesforce/stg_salesforce__opportunity_line_item.sql @@ -23,15 +23,15 @@ final as ( {{ coalesce_w_renamed_col('created_date', datatype=dbt.type_timestamp()) }}, description as opportunity_line_item_description, discount, - {{ coalesce_w_renamed_col('has_quantity_schedule') }}, - {{ coalesce_w_renamed_col('has_revenue_schedule') }}, - {{ coalesce_w_renamed_col('has_schedule') }}, - {{ coalesce_w_renamed_col('is_deleted') }}, + {{ coalesce_w_renamed_col('has_quantity_schedule', datatype=dbt.type_boolean()) }}, + {{ coalesce_w_renamed_col('has_revenue_schedule', datatype=dbt.type_boolean()) }}, + {{ coalesce_w_renamed_col('has_schedule', datatype=dbt.type_boolean()) }}, + {{ coalesce_w_renamed_col('is_deleted', datatype=dbt.type_boolean()) }}, {{ coalesce_w_renamed_col('last_modified_by_id') }}, {{ coalesce_w_renamed_col('last_modified_date', datatype=dbt.type_timestamp()) }}, {{ coalesce_w_renamed_col('last_referenced_date', datatype=dbt.type_timestamp()) }}, {{ coalesce_w_renamed_col('last_viewed_date', datatype=dbt.type_timestamp()) }}, - {{ coalesce_w_renamed_col('list_price') }}, + {{ coalesce_w_renamed_col('list_price', datatype=dbt.type_numeric()) }}, name as opportunity_line_item_name, {{ coalesce_w_renamed_col('opportunity_id') }}, {{ coalesce_w_renamed_col('pricebook_entry_id') }}, @@ -39,9 +39,9 @@ final as ( {{ coalesce_w_renamed_col('product_code') }}, quantity, {{ coalesce_w_renamed_col('service_date', datatype=dbt.type_timestamp()) }}, - {{ coalesce_w_renamed_col('sort_order') }}, - {{ coalesce_w_renamed_col('total_price') }}, - {{ coalesce_w_renamed_col('unit_price') }} + {{ coalesce_w_renamed_col('sort_order', datatype=dbt.type_int()) }}, + {{ coalesce_w_renamed_col('total_price', datatype=dbt.type_numeric()) }}, + {{ coalesce_w_renamed_col('unit_price', datatype=dbt.type_numeric()) }} {{ fivetran_utils.fill_pass_through_columns('salesforce__opportunity_line_item_pass_through_columns') }} diff --git a/models/salesforce/stg_salesforce__order.sql b/models/salesforce/stg_salesforce__order.sql index f005afb..0709dcf 100644 --- a/models/salesforce/stg_salesforce__order.sql +++ b/models/salesforce/stg_salesforce__order.sql @@ -31,10 +31,10 @@ final as ( {{ coalesce_w_renamed_col('billing_street') }}, {{ coalesce_w_renamed_col('contract_id') }}, {{ coalesce_w_renamed_col('created_by_id') }}, - {{ coalesce_w_renamed_col('created_date') }}, + {{ coalesce_w_renamed_col('created_date', datatype=dbt.type_timestamp()) }}, description as order_description, {{ coalesce_w_renamed_col('end_date', datatype=dbt.type_timestamp()) }}, - {{ coalesce_w_renamed_col('is_deleted') }}, + {{ coalesce_w_renamed_col('is_deleted', datatype=dbt.type_boolean()) }}, {{ coalesce_w_renamed_col('last_modified_by_id') }}, {{ coalesce_w_renamed_col('last_modified_date', datatype=dbt.type_timestamp()) }}, {{ coalesce_w_renamed_col('last_referenced_date', datatype=dbt.type_timestamp()) }}, @@ -52,7 +52,7 @@ final as ( {{ coalesce_w_renamed_col('shipping_state_code') }}, {{ coalesce_w_renamed_col('shipping_street') }}, status, - {{ coalesce_w_renamed_col('total_amount') }}, + {{ coalesce_w_renamed_col('total_amount', datatype=dbt.type_numeric()) }}, type {{ fivetran_utils.fill_pass_through_columns('salesforce__order_pass_through_columns') }} diff --git a/models/salesforce/stg_salesforce__product_2.sql b/models/salesforce/stg_salesforce__product_2.sql index f69f048..dc3d347 100644 --- a/models/salesforce/stg_salesforce__product_2.sql +++ b/models/salesforce/stg_salesforce__product_2.sql @@ -25,16 +25,16 @@ final as ( {{ coalesce_w_renamed_col('display_url') }}, {{ coalesce_w_renamed_col('external_id') }}, family, - {{ coalesce_w_renamed_col('is_active') }}, - {{ coalesce_w_renamed_col('is_archived') }}, - {{ coalesce_w_renamed_col('is_deleted') }}, + {{ coalesce_w_renamed_col('is_active', datatype=dbt.type_boolean()) }}, + {{ coalesce_w_renamed_col('is_archived', datatype=dbt.type_boolean()) }}, + {{ coalesce_w_renamed_col('is_deleted', datatype=dbt.type_boolean()) }}, {{ coalesce_w_renamed_col('last_modified_by_id') }}, {{ coalesce_w_renamed_col('last_modified_date', datatype=dbt.type_timestamp()) }}, {{ coalesce_w_renamed_col('last_referenced_date', datatype=dbt.type_timestamp()) }}, {{ coalesce_w_renamed_col('last_viewed_date', datatype=dbt.type_timestamp()) }}, name as product_2_name, - {{ coalesce_w_renamed_col('number_of_quantity_installments') }}, - {{ coalesce_w_renamed_col('number_of_revenue_installments') }}, + {{ coalesce_w_renamed_col('number_of_quantity_installments', datatype=dbt.type_int()) }}, + {{ coalesce_w_renamed_col('number_of_revenue_installments', datatype=dbt.type_int()) }}, {{ coalesce_w_renamed_col('product_code') }}, {{ coalesce_w_renamed_col('quantity_installment_period') }}, {{ coalesce_w_renamed_col('quantity_schedule_type') }}, diff --git a/models/salesforce/stg_salesforce__task.sql b/models/salesforce/stg_salesforce__task.sql index 7fef701..01818e5 100644 --- a/models/salesforce/stg_salesforce__task.sql +++ b/models/salesforce/stg_salesforce__task.sql @@ -22,16 +22,16 @@ final as ( {{ coalesce_w_renamed_col('account_id') }}, {{ coalesce_w_renamed_col('activity_date', datatype=dbt.type_timestamp()) }}, {{ coalesce_w_renamed_col('call_disposition') }}, - {{ coalesce_w_renamed_col('call_duration_in_seconds') }}, + {{ coalesce_w_renamed_col('call_duration_in_seconds', datatype=dbt.type_int()) }}, {{ coalesce_w_renamed_col('call_object') }}, {{ coalesce_w_renamed_col('call_type') }}, {{ coalesce_w_renamed_col('completed_date_time', datatype=dbt.type_timestamp()) }}, {{ coalesce_w_renamed_col('created_by_id') }}, {{ coalesce_w_renamed_col('created_date', datatype=dbt.type_timestamp()) }}, description as task_description, - {{ coalesce_w_renamed_col('is_archived') }}, - {{ coalesce_w_renamed_col('is_closed') }}, - {{ coalesce_w_renamed_col('is_deleted') }}, + {{ coalesce_w_renamed_col('is_archived', datatype=dbt.type_boolean()) }}, + {{ coalesce_w_renamed_col('is_closed', datatype=dbt.type_boolean()) }}, + {{ coalesce_w_renamed_col('is_deleted', datatype=dbt.type_boolean()) }}, {{ coalesce_w_renamed_col('is_high_priority') }}, {{ coalesce_w_renamed_col('last_modified_by_id') }}, {{ coalesce_w_renamed_col('last_modified_date', datatype=dbt.type_timestamp()) }}, @@ -42,9 +42,9 @@ final as ( subject, {{ coalesce_w_renamed_col('task_subtype') }}, type, - {{ coalesce_w_renamed_col('what_count') }}, + {{ coalesce_w_renamed_col('what_count', datatype=dbt.type_int()) }}, {{ coalesce_w_renamed_col('what_id') }}, - {{ coalesce_w_renamed_col('who_count') }}, + {{ coalesce_w_renamed_col('who_count', datatype=dbt.type_int()) }}, {{ coalesce_w_renamed_col('who_id') }} {{ fivetran_utils.fill_pass_through_columns('salesforce__task_pass_through_columns') }} diff --git a/models/salesforce/stg_salesforce__user.sql b/models/salesforce/stg_salesforce__user.sql index d5a3fc3..18eb695 100644 --- a/models/salesforce/stg_salesforce__user.sql +++ b/models/salesforce/stg_salesforce__user.sql @@ -30,7 +30,7 @@ final as ( {{ coalesce_w_renamed_col('first_name') }}, id as user_id, {{ coalesce_w_renamed_col('individual_id') }}, - {{ coalesce_w_renamed_col('is_active') }}, + {{ coalesce_w_renamed_col('is_active', datatype=dbt.type_boolean()) }}, {{ coalesce_w_renamed_col('last_login_date', datatype=dbt.type_timestamp()) }}, {{ coalesce_w_renamed_col('last_name') }}, {{ coalesce_w_renamed_col('last_referenced_date', datatype=dbt.type_timestamp()) }}, From 4a252f21259d0d7d63488fe699bf26324d8a897a Mon Sep 17 00:00:00 2001 From: fivetran-catfritz <111930712+fivetran-catfritz@users.noreply.github.com> Date: Mon, 1 Jul 2024 12:18:17 -0500 Subject: [PATCH 6/7] add casting for all --- models/salesforce/stg_salesforce__task.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models/salesforce/stg_salesforce__task.sql b/models/salesforce/stg_salesforce__task.sql index 01818e5..553d8ba 100644 --- a/models/salesforce/stg_salesforce__task.sql +++ b/models/salesforce/stg_salesforce__task.sql @@ -32,7 +32,7 @@ final as ( {{ coalesce_w_renamed_col('is_archived', datatype=dbt.type_boolean()) }}, {{ coalesce_w_renamed_col('is_closed', datatype=dbt.type_boolean()) }}, {{ coalesce_w_renamed_col('is_deleted', datatype=dbt.type_boolean()) }}, - {{ coalesce_w_renamed_col('is_high_priority') }}, + {{ coalesce_w_renamed_col('is_high_priority', datatype=dbt.type_boolean()) }}, {{ coalesce_w_renamed_col('last_modified_by_id') }}, {{ coalesce_w_renamed_col('last_modified_date', datatype=dbt.type_timestamp()) }}, {{ coalesce_w_renamed_col('owner_id') }}, From f47bd73cd4737e6a2618eaa53eb8089edb86ff72 Mon Sep 17 00:00:00 2001 From: fivetran-catfritz <111930712+fivetran-catfritz@users.noreply.github.com> Date: Mon, 1 Jul 2024 18:07:49 -0500 Subject: [PATCH 7/7] macro updates --- macros/coalesce_w_renamed_col.sql | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/macros/coalesce_w_renamed_col.sql b/macros/coalesce_w_renamed_col.sql index 4fec8f4..eab3562 100644 --- a/macros/coalesce_w_renamed_col.sql +++ b/macros/coalesce_w_renamed_col.sql @@ -1,10 +1,8 @@ -{% macro coalesce_w_renamed_col(original_column_name, datatype=dbt.type_string()) %} +{% macro coalesce_w_renamed_col(original_column_name, datatype=dbt.type_string(), alias=original_column_name, renamed_column_name=original_column_name.replace('_', '')) %} {# This macro accomodates Fivetran connectors that keep the original salesforce field naming conventions without underscores #} -{%- set renamed_col = original_column_name.replace('_', '') -%} - -coalesce(cast({{ renamed_col }} as {{ datatype }}), +coalesce(cast({{ renamed_column_name }} as {{ datatype }}), cast({{ original_column_name }} as {{ datatype }})) - as {{ original_column_name }} + as {{ alias }} {%- endmacro %} \ No newline at end of file