diff --git a/models/intermediate/hubspot/int_hubspot__deal.sql b/models/intermediate/hubspot/int_hubspot__deal.sql index ad1913d..73b37be 100644 --- a/models/intermediate/hubspot/int_hubspot__deal.sql +++ b/models/intermediate/hubspot/int_hubspot__deal.sql @@ -23,6 +23,9 @@ select d.amount_of_properties, d.last_contacted_date_utc, d.amount_times_contacted, + d.dashboard_type, + d.pricing_structure, + d.partnership_services, d.created_at_utc, d.created_date_utc, d.updated_at_utc, diff --git a/models/intermediate/hubspot/schema.yml b/models/intermediate/hubspot/schema.yml index 8344d1e..79eff1a 100644 --- a/models/intermediate/hubspot/schema.yml +++ b/models/intermediate/hubspot/schema.yml @@ -80,6 +80,31 @@ models: data_type: integer description: Amount of times the account has been contacted + - name: dashboard_type + data_type: text + description: | + The type of dashboard that the customer has access to. This applies + for platform clients, and can be either Legacy or New. + It can be null. + + - name: pricing_structure + data_type: text + description: | + The pricing structure that the customer has. It can be null. + + - name: partnership_services + data_type: text + description: | + The partnership type, i.e., the services that the client has + according to hubspot. This field has been processed by applying a + standardized separation "|" and an upper case. Be aware that this + is not how data is presented in HubSpot. + Be aware that this might not capture the full history of services + that the client has had in the past, nor necessarily be always + up-to-date. For New Dash clients, please refer to backend data + for complete accuracy. + It can be null. + - name: created_at_utc data_type: timestamp with time zone description: Timestamp of when the record was created in Hubspot diff --git a/models/staging/hubspot/schema.yml b/models/staging/hubspot/schema.yml index 4324e96..6bb76d8 100644 --- a/models/staging/hubspot/schema.yml +++ b/models/staging/hubspot/schema.yml @@ -376,6 +376,48 @@ models: data_type: jsonb description: "" + - name: dashboard_type + data_type: text + description: | + The type of dashboard that the customer has access to. This applies + for platform clients, and can be either Legacy or New. + It can be null. + data_tests: + - accepted_values: + values: + - Legacy + - New + + - name: pricing_structure + data_type: text + description: | + The pricing structure that the customer has. It can be null. + + - name: partnership_services_raw + data_type: text + description: | + The partnership type, i.e., the services that the client has + according to hubspot. This exactly matches the input as is from + HubSpot, in the sense that no processing has been applied. + Be aware that this might not capture the full history of services + that the client has had in the past, nor necessarily be always + up-to-date. For New Dash clients, please refer to backend data + for complete accuracy. + It can be null. + + - name: partnership_services + data_type: text + description: | + The partnership type, i.e., the services that the client has + according to hubspot. This field has been processed by applying a + standardized separation "|" and an upper case. Be aware that this + is not how data is presented in HubSpot. + Be aware that this might not capture the full history of services + that the client has had in the past, nor necessarily be always + up-to-date. For New Dash clients, please refer to backend data + for complete accuracy. + It can be null. + - name: created_at_utc data_type: timestamp with time zone description: "" diff --git a/models/staging/hubspot/stg_hubspot__deals.sql b/models/staging/hubspot/stg_hubspot__deals.sql index babc061..9de1fb7 100644 --- a/models/staging/hubspot/stg_hubspot__deals.sql +++ b/models/staging/hubspot/stg_hubspot__deals.sql @@ -75,6 +75,30 @@ with cast( {{ adapter.quote("properties") }} ->> 'free_trial_end_date' as date ) as free_trial_end_date_utc, + + {{ adapter.quote("properties") }} ->> 'dashboard' as dashboard_type, + {{ adapter.quote("properties") }} + ->> 'pricing_structure' as pricing_structure, + {{ adapter.quote("properties") }} + ->> 'partnership_type_' as raw_partnership_services, + -- Partnership services are stored as a string with multiple values + -- separated by either / or + and these can contain leading or trailing + -- spaces. In the following field we apply a standardization to the + -- values by replacing the separators with | and converting the values + -- to uppercase. The regex applied is: + -- \s* → Matches any leading or trailing spaces. + -- [+/] → Matches either / or + as separators. + -- \s* → Again, ensures spaces around the separator are also replaced. + -- 'g' → Applies the replacement globally (to all occurrences in the + -- string). + upper( + regexp_replace( + {{ adapter.quote("properties") }} ->> 'partnership_type_', + '\s*[+/]\s*', + '|', + 'g' + ) + ) as partnership_services, {{ adapter.quote("properties") }} as properties, {{ adapter.quote("createdAt") }} as created_at_utc, cast({{ adapter.quote("createdAt") }} as date) as created_date_utc,