Skip to content

Commit

Permalink
Merge pull request #46 from fivetran/bugfix/sla-datatype-updates
Browse files Browse the repository at this point in the history
Bugfix/sla datatype updates
  • Loading branch information
fivetran-joemarkiewicz authored Feb 21, 2024
2 parents 75d9621 + 491bcf3 commit ce4da6b
Show file tree
Hide file tree
Showing 17 changed files with 48 additions and 60 deletions.
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
# dbt_zendesk_source v0.11.0

[PR #46](https://github.com/fivetran/dbt_zendesk_source/pull/46) includes the following updates:

## 🚨 Breaking Change Bug Fixes 🚨
- Updated the following staging models to leverage the `{{ dbt.type_timestamp() }}` macro on timestamp fields in order to ensure timestamp with no timezone is used in downstream models. This update will cause timestamps to be converted to have no timezone. If records were reported as timezone timestamps before, this will result in converted timestamp records.
- `stg_zendesk__ticket`
- `stg_zendesk__ticket_comment`
- `stg_zendesk__ticket_field_history`
- `stg_zendesk__ticket_form_history`
- `stg_zendesk__ticket_schedule`
- `stg_zendesk__user`

## Documentation Updates
- Updated "Zendesk" references within the README to now refer to "Zendesk Support" in order to more accurately reflect the name of the Fivetran Zendesk Support Connector.

# dbt_zendesk_source v0.10.1
[PR #43](https://github.com/fivetran/dbt_zendesk_source/pull/43) introduces the following updates:

Expand Down
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,21 @@
<img src="https://img.shields.io/badge/Fivetran_Quickstart_Compatible%3F-yes-green.svg" /></a>
</p>

# Zendesk Source dbt Package ([Docs](https://fivetran.github.io/dbt_zendesk_source/))
# Zendesk Support Source dbt Package ([Docs](https://fivetran.github.io/dbt_zendesk_source/))
# 📣 What does this dbt package do?
<!--section="zendesk_source_model"-->
- Materializes [Zendesk staging tables](https://fivetran.github.io/dbt_github_source/#!/overview/zendesk_source/models/?g_v=1) which leverage data in the format described by [this ERD](https://fivetran.com/docs/applications/zendesk#schemainformation). These staging tables clean, test, and prepare your Zendesk data from [Fivetran's connector](https://fivetran.com/docs/applications/zendesk) for analysis by doing the following:
- Materializes [Zendesk Support staging tables](https://fivetran.github.io/dbt_github_source/#!/overview/zendesk_source/models/?g_v=1) which leverage data in the format described by [this ERD](https://fivetran.com/docs/applications/zendesk#schemainformation). These staging tables clean, test, and prepare your Zendesk Support data from [Fivetran's connector](https://fivetran.com/docs/applications/zendesk) for analysis by doing the following:
- Name columns for consistency across all packages and for easier analysis
- Adds freshness tests to source data
- Adds column-level testing where applicable. For example, all primary keys are tested for uniqueness and non-null values.
- Generates a comprehensive data dictionary of your Zendesk data through the [dbt docs site](https://fivetran.github.io/dbt_zendesk_source/).
- These tables are designed to work simultaneously with our [Zendesk transformation package](https://github.com/fivetran/dbt_zendesk).
- Generates a comprehensive data dictionary of your Zendesk Support data through the [dbt docs site](https://fivetran.github.io/dbt_zendesk_source/).
- These tables are designed to work simultaneously with our [Zendesk Support transformation package](https://github.com/fivetran/dbt_zendesk).
<!--section-end-->

# 🎯 How do I use the dbt package?
## Step 1: Prerequisites
To use this dbt package, you must have the following:
- A Fivetran Zendesk connector syncing data into your destination.
- A Fivetran Zendesk Support connector syncing data into your destination.
- A **BigQuery**, **Snowflake**, **Redshift**, **PostgreSQL**, or **Databricks** destination.

### Databricks Dispatch Configuration
Expand All @@ -39,23 +39,23 @@ dispatch:
```
## Step 2: Install the package
Include the following zendesk_source package version in your `packages.yml` file **only if you are NOT also installing the [Zendesk transformation package](https://github.com/fivetran/dbt_zendesk)**. The transform package has a dependency on this source package.
Include the following zendesk_source package version in your `packages.yml` file **only if you are NOT also installing the [Zendesk Support transformation package](https://github.com/fivetran/dbt_zendesk)**. The transform package has a dependency on this source package.
> TIP: Check [dbt Hub](https://hub.getdbt.com/) for the latest installation instructions or [read the dbt docs](https://docs.getdbt.com/docs/package-management) for more information on installing packages.
```yaml
packages:
- package: fivetran/zendesk_source
version: [">=0.10.0", "<0.11.0"]
version: [">=0.11.0", "<0.12.0"]
```
## Step 3: Define database and schema variables
By default, this package runs using your target database and the `zendesk` schema. If this is not where your Zendesk data is (for example, if your zendesk schema is named `zendesk_fivetran`), add the following configuration to your root `dbt_project.yml` file:
By default, this package runs using your target database and the `zendesk` schema. If this is not where your Zendesk Support data is (for example, if your zendesk schema is named `zendesk_fivetran`), add the following configuration to your root `dbt_project.yml` file:

```yml
vars:
zendesk_database: your_destination_name
zendesk_schema: your_schema_name
```
## Step 4: Disable models for non-existent sources
This package takes into consideration that not every Zendesk account utilizes the `schedule`, `domain_name`, `user_tag`, `organization_tag`, or `ticket_form_history` features, and allows you to disable the corresponding functionality. By default, all variables' values are assumed to be `true`. Add variables for only the tables you want to disable:
This package takes into consideration that not every Zendesk Support account utilizes the `schedule`, `domain_name`, `user_tag`, `organization_tag`, or `ticket_form_history` features, and allows you to disable the corresponding functionality. By default, all variables' values are assumed to be `true`. Add variables for only the tables you want to disable:
```yml
vars:
using_schedules: False #Disable if you are not using schedules
Expand Down Expand Up @@ -88,7 +88,7 @@ vars:
```

### Change the build schema
By default, this package builds the zendesk staging models within a schema titled (`<target_schema>` + `_zendesk_source`) in your target database. If this is not where you would like your Zendesk staging data to be written to, add the following configuration to your root `dbt_project.yml` file:
By default, this package builds the zendesk staging models within a schema titled (`<target_schema>` + `_zendesk_source`) in your target database. If this is not where you would like your Zendesk Support staging data to be written to, add the following configuration to your root `dbt_project.yml` file:

```yml
models:
Expand Down
2 changes: 1 addition & 1 deletion dbt_project.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
config-version: 2
name: 'zendesk_source'
version: '0.10.1'
version: '0.11.0'
require-dbt-version: [">=1.3.0", "<2.0.0"]
models:
zendesk_source:
Expand Down
2 changes: 1 addition & 1 deletion docs/catalog.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/index.html

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion integration_tests/dbt_project.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
config-version: 2

name: 'zendesk_source_integration_tests'
version: '0.10.1'
version: '0.11.0'

profile: 'integration_tests'

Expand Down
2 changes: 1 addition & 1 deletion models/src_zendesk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ sources:

- name: user
identifier: "{{ var('zendesk_user_identifier', 'user') }}"
description: Zendesk has three types of users, end-users (your customers), agents, and administrators.
description: Zendesk Support has three types of users, end-users (your customers), agents, and administrators.
freshness: null
columns:
- name: id
Expand Down
2 changes: 1 addition & 1 deletion models/stg_zendesk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ models:
description: Tag associated with the user

- name: stg_zendesk__user
description: Zendesk has three types of users, end-users (your customers), agents, and administrators.
description: Zendesk Support has three types of users, end-users (your customers), agents, and administrators.
columns:
- name: user_id
description: Automatically assigned when the user is created
Expand Down
9 changes: 2 additions & 7 deletions models/stg_zendesk__ticket.sql
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,8 @@ final as (
_fivetran_synced,
assignee_id,
brand_id,
{% if target.type == 'redshift' -%}
cast(created_at as timestamp without time zone) as created_at,
cast(updated_at as timestamp without time zone) as updated_at,
{% else -%}
created_at,
updated_at,
{% endif %}
cast(created_at as {{ dbt.type_timestamp() }}) as created_at,
cast(updated_at as {{ dbt.type_timestamp() }}) as updated_at,
description,
due_at,
group_id,
Expand Down
6 changes: 1 addition & 5 deletions models/stg_zendesk__ticket_comment.sql
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,7 @@ final as (
id as ticket_comment_id,
_fivetran_synced,
body,
{% if target.type == 'redshift' -%}
cast(created as timestamp without time zone) as created_at,
{% else -%}
created as created_at,
{% endif %}
cast(created as {{ dbt.type_timestamp() }}) as created_at,
public as is_public,
ticket_id,
user_id,
Expand Down
9 changes: 2 additions & 7 deletions models/stg_zendesk__ticket_field_history.sql
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,8 @@ final as (
select
ticket_id,
field_name,
{% if target.type == 'redshift' -%}
cast(updated as timestamp without time zone) as valid_starting_at,
cast(lead(updated) over (partition by ticket_id, field_name order by updated) as timestamp without time zone) as valid_ending_at,
{% else -%}
updated as valid_starting_at,
lead(updated) over (partition by ticket_id, field_name order by updated) as valid_ending_at,
{% endif %}
cast(updated as {{ dbt.type_timestamp() }}) as valid_starting_at,
cast(lead(updated) over (partition by ticket_id, field_name order by updated) as {{ dbt.type_timestamp() }}) as valid_ending_at,
value,
user_id
from fields
Expand Down
9 changes: 2 additions & 7 deletions models/stg_zendesk__ticket_form_history.sql
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,8 @@ final as (

select
id as ticket_form_id,
{% if target.type == 'redshift' -%}
cast(created_at as timestamp without time zone) as created_at,
cast(updated_at as timestamp without time zone) as updated_at,
{% else -%}
created_at,
updated_at,
{% endif %}
cast(created_at as {{ dbt.type_timestamp() }}) as created_at,
cast(updated_at as {{ dbt.type_timestamp() }}) as updated_at,
display_name,
active as is_active,
name
Expand Down
6 changes: 1 addition & 5 deletions models/stg_zendesk__ticket_schedule.sql
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,7 @@ final as (

select
ticket_id,
{% if target.type == 'redshift' -%}
cast(created_at as timestamp without time zone) as created_at,
{% else -%}
created_at,
{% endif %}
cast(created_at as {{ dbt.type_timestamp() }}) as created_at,
cast(schedule_id as {{ dbt.type_string() }}) as schedule_id --need to convert from numeric to string for downstream models to work properly
from fields
)
Expand Down
3 changes: 2 additions & 1 deletion models/stg_zendesk__time_zone.sql
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,5 @@ final as (
from fields
)

select * from final
select *
from final
12 changes: 3 additions & 9 deletions models/stg_zendesk__user.sql
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,9 @@ final as (
id as user_id,
external_id,
_fivetran_synced,
{% if target.type == 'redshift' -%}
cast(last_login_at as timestamp without time zone) as last_login_at,
cast(created_at as timestamp without time zone) as created_at,
cast(updated_at as timestamp without time zone) as updated_at,
{% else -%}
last_login_at,
created_at,
updated_at,
{% endif -%}
cast(last_login_at as {{ dbt.type_timestamp() }}) as last_login_at,
cast(created_at as {{ dbt.type_timestamp() }}) as created_at,
cast(updated_at as {{ dbt.type_timestamp() }}) as updated_at,
email,
name,
organization_id,
Expand Down

0 comments on commit ce4da6b

Please sign in to comment.