{"id":22793245,"url":"https://github.com/fivetran/dbt_zendesk_source","last_synced_at":"2025-04-16T18:49:25.616Z","repository":{"id":40362876,"uuid":"262427854","full_name":"fivetran/dbt_zendesk_source","owner":"fivetran","description":"Fivetran's Zendesk Support source dbt package","archived":false,"fork":false,"pushed_at":"2025-03-11T18:48:32.000Z","size":2797,"stargazers_count":13,"open_issues_count":5,"forks_count":19,"subscribers_count":41,"default_branch":"main","last_synced_at":"2025-03-29T05:33:47.523Z","etag":null,"topics":["dbt","dbt-packages","fivetran","zendesk"],"latest_commit_sha":null,"homepage":"https://fivetran.github.io/dbt_zendesk_source/#!/overview","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fivetran.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-05-08T21:00:33.000Z","updated_at":"2025-03-04T22:21:24.000Z","dependencies_parsed_at":"2023-02-06T07:46:02.447Z","dependency_job_id":"7126dfae-beab-4da2-99e4-88fdbb4e1c29","html_url":"https://github.com/fivetran/dbt_zendesk_source","commit_stats":null,"previous_names":[],"tags_count":27,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fivetran%2Fdbt_zendesk_source","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fivetran%2Fdbt_zendesk_source/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fivetran%2Fdbt_zendesk_source/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fivetran%2Fdbt_zendesk_source/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fivetran","download_url":"https://codeload.github.com/fivetran/dbt_zendesk_source/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249266509,"owners_count":21240767,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dbt","dbt-packages","fivetran","zendesk"],"created_at":"2024-12-12T03:18:46.286Z","updated_at":"2025-04-16T18:49:25.605Z","avatar_url":"https://github.com/fivetran.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Zendesk Support Source dbt Package ([Docs](https://fivetran.github.io/dbt_zendesk_source/))\n\n\u003cp align=\"left\"\u003e\n    \u003ca alt=\"License\"\n        href=\"https://github.com/fivetran/dbt_zendesk_source/blob/main/LICENSE\"\u003e\n        \u003cimg src=\"https://img.shields.io/badge/License-Apache%202.0-blue.svg\" /\u003e\u003c/a\u003e\n    \u003ca alt=\"dbt-core\"\u003e\n        \u003cimg src=\"https://img.shields.io/badge/dbt_Core™_version-\u003e=1.3.0_\u003c2.0.0-orange.svg\" /\u003e\u003c/a\u003e\n    \u003ca alt=\"Maintained?\"\u003e\n        \u003cimg src=\"https://img.shields.io/badge/Maintained%3F-yes-green.svg\" /\u003e\u003c/a\u003e\n    \u003ca alt=\"PRs\"\u003e\n        \u003cimg src=\"https://img.shields.io/badge/Contributions-welcome-blueviolet\" /\u003e\u003c/a\u003e\n    \u003ca alt=\"Fivetran Quickstart Compatible\"\n        href=\"https://fivetran.com/docs/transformations/dbt/quickstart\"\u003e\n        \u003cimg src=\"https://img.shields.io/badge/Fivetran_Quickstart_Compatible%3F-yes-green.svg\" /\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n## What does this dbt package do?\n\u003c!--section=\"zendesk_source_model\"--\u003e\n- 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:\n  - Name columns for consistency across all packages and for easier analysis\n  - Adds freshness tests to source data\n  - Adds column-level testing where applicable. For example, all primary keys are tested for uniqueness and non-null values.\n- Generates a comprehensive data dictionary of your Zendesk Support data through the [dbt docs site](https://fivetran.github.io/dbt_zendesk_source/).\n- These tables are designed to work simultaneously with our [Zendesk Support transformation package](https://github.com/fivetran/dbt_zendesk).\n\u003c!--section-end--\u003e\n\n## How do I use the dbt package?\n### Step 1: Prerequisites\nTo use this dbt package, you must have the following:\n- A Fivetran Zendesk Support connection syncing data into your destination.\n- A **BigQuery**, **Snowflake**, **Redshift**, **PostgreSQL**, or **Databricks** destination.\n\n#### Databricks Dispatch Configuration\nIf you are using a Databricks destination with this package you will need to add the below (or a variation of the below) dispatch configuration within your `dbt_project.yml`. This is required in order for the package to accurately search for macros within the `dbt-labs/spark_utils` then the `dbt-labs/dbt_utils` packages respectively.\n```yml\ndispatch:\n  - macro_namespace: dbt_utils\n    search_order: ['spark_utils', 'dbt_utils']\n```\n\n### Step 2: Install the package (skip if using `zendesk` transformation package)\nInclude 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.\n\u003e 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.\n```yaml\npackages:\n  - package: fivetran/zendesk_source\n    version: [\"\u003e=0.15.0\", \"\u003c0.16.0\"]\n```\n### Step 3: Define database and schema variables\n#### Option A: Single connection\nBy 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:\n\n```yml\nvars:\n    zendesk_database: your_destination_name\n    zendesk_schema: your_schema_name \n```\n\u003e **Note**: When running the package with a single source connection, the `source_relation` column in each model will be populated with an empty string.\n\n#### Option B: Union multiple connections\nIf you have multiple Zendesk connections in Fivetran and would like to use this package on all of them simultaneously, we have provided functionality to do so. For each source table, the package will union all of the data together and pass the unioned table into the transformations. The `source_relation` column in each model indicates the origin of each record. \n\nTo use this functionality, you will need to set the `zendesk_sources` variable in your root `dbt_project.yml` file:\n\n```yml\n# dbt_project.yml\n\nvars:\n  zendesk_sources:\n    - database: connection_1_destination_name # Required\n      schema: connection_1_schema_name # Rquired\n      name: connection_1_source_name # Required only if following the step in the following subsection\n\n    - database: connection_2_destination_name\n      schema: connection_2_schema_name\n      name: connection_2_source_name\n```\n\n##### Recommended: Incorporate unioned sources into DAG\n\u003e *If you are running the package through [Fivetran Transformations for dbt Core™](https://fivetran.com/docs/transformations/dbt#transformationsfordbtcore), the below step is necessary in order to synchronize model runs with your Zendesk connections.*\n\nBy default, this package defines one single-connection source, called `zendesk`, which will be disabled if you are unioning multiple connections. This means that your DAG will not include your Zendesk sources, though the package will run successfully.\n\nTo properly incorporate all of your Zendesk connections into your project's DAG:\n1. Define each of your sources in a `.yml` file in your project. Utilize the following template for the `source`-level configurations, and, **most importantly**, copy and paste the table and column-level definitions from the package's `src_zendesk.yml` [file](https://github.com/fivetran/dbt_zendesk_source/blob/main/models/src_zendesk.yml#L15-L351).\n\n```yml\n# a .yml file in your root project\nsources:\n  - name: \u003cname\u003e # ex: Should match name in zendesk_sources\n    schema: \u003cschema_name\u003e\n    database: \u003cdatabase_name\u003e\n    loader: fivetran\n    loaded_at_field: _fivetran_synced\n      \n    freshness: # feel free to adjust to your liking\n      warn_after: {count: 72, period: hour}\n      error_after: {count: 168, period: hour}\n\n    tables: # copy and paste from models/src_zendesk.yml - see https://support.atlassian.com/bitbucket-cloud/docs/yaml-anchors/ for how to use anchors to only do so once\n```\n\n\u003e **Note**: If there are source tables you do not have (see [Step 4](https://github.com/fivetran/dbt_zendesk_source?tab=readme-ov-file#step-4-disable-models-for-non-existent-sources)), still include them in this source definition.\n\n2. Set the `has_defined_sources` variable (scoped to the `zendesk_source` package) to `True`, like such:\n```yml\n# dbt_project.yml\nvars:\n  zendesk_source:\n    has_defined_sources: true\n```\n\n### Step 4: Enable/Disable models for non-existent sources\n\u003e _This step is optional if you are unioning multiple connections together in the previous step. The `union_data` macro will create empty staging models for sources that are not found in any of your Zendesk schemas/databases. However, you can still leverage the below variables if you would like to avoid this behavior._\n\nThis package takes into consideration that not every Zendesk Support account utilizes the `schedule`, `schedule_holiday`, `ticket_schedule`, `daylight_time`, `time_zone`, `audit_log`, `domain_name`, `user_tag`,  `brand`, `organization`, `organization_tag`, or `ticket_form_history` features, and allows you to disable the corresponding functionality.\n\nBy default, all variables' values are assumed to be `true`, except for `using_schedule_histories`. Add variables for only the tables you want to enable/disable:\n\n```yml\nvars:\n    using_schedule_histories:   True          #Enable if you are using audit_logs for schedule histories\n    using_schedules:            False         #Disable if you are not using schedules, which requires source tables ticket_schedule, daylight_time, and time_zone\n    using_holidays:             False         #Disable if you are not using schedule_holidays for holidays\n    using_domain_names:         False         #Disable if you are not using domain names\n    using_user_tags:            False         #Disable if you are not using user tags\n    using_ticket_form_history:  False         #Disable if you are not using ticket form history\n    using_brands:               False         #Disable if you are not using brands\n    using_organizations:        False         #Disable if you are not using organizations. Setting this to False will also disable organization tags. \n    using_organization_tags:    False         #Disable if you are not using organization tags.\n```\n\n### (Optional) Step 5: Additional configurations\n\u003cdetails open\u003e\u003csummary\u003eCollapse/Expand configurations\u003c/summary\u003e\n\n#### Add passthrough columns\nThis package includes all source columns defined in the macros folder. You can add more columns from the `TICKET`, `USER`, and `ORGANIZATION` tables using our pass-through column variables, which will persist these custom fields to the `stg_zendesk__ticket`, `stg_zendesk__user`, and `stg_zendesk__organization` models, respectively.\n\nThese variables allow for the pass-through fields to be aliased (`alias`) and casted (`transform_sql`) if desired, but not required. Datatype casting is configured via a sql snippet within the `transform_sql` key. You may add the desired sql while omitting the `as field_name` at the end and your custom pass-through fields will be casted accordingly. Use the below format for declaring the respective pass-through variables:\n\n```yml\nvars:\n  zendesk__ticket_passthrough_columns:\n    - name: \"account_custom_field_1\" # required\n      alias: \"account_1\" # optional\n      transform_sql: \"cast(account_1 as string)\" # optional, must reference the alias if an alias is provided (otherwise the original name)\n    - name: \"account_custom_field_2\"\n      transform_sql: \"cast(account_custom_field_2 as string)\"\n    - name: \"account_custom_field_3\"\n  zendesk__user_passthrough_columns:\n    - name: \"internal_app_id_c\"\n      alias: \"app_id\"\n  zendesk__organization_passthrough_columns:\n    - name: \"custom_org_field_1\"\n```\n\n\u003e Note: Earlier versions of this package employed a more rudimentary format for passthrough columns, in which the user provided a list of field names to pass in, rather than a mapping. In the above `ticket` example, this would be `[account_custom_field_1, account_custom_field_2, account_custom_field_3]`.\n\u003e\n\u003e This old format will still work, as our passthrough-column macros are all backwards compatible.\n\n#### Mark Former Internal Users as Agents\nIf a team member leaves your organization and their internal account is deactivated, their `USER.role` will switch from `agent` or `admin` to `end-user`. This will skew historical ticket SLA metrics, as we calculate reply times and other metrics based on `agent` or `admin` activity only.\n\nTo persist the integrity of historical ticket SLAs and mark these former team members as agents, provide the `internal_user_criteria` variable with a SQL clause to identify them, based on fields in the `USER` table. This SQL will be wrapped in a `case when` statement in the `stg_zendesk__user` model.\n\nExample usage:\n```yml\n# dbt_project.yml\nvars:\n  zendesk_source:\n    internal_user_criteria: \"lower(email) like '%@fivetran.com' or external_id = '12345' or name in ('Garrett', 'Alfredo')\" # can reference any non-custom field in USER\n```\n\n#### Change the build schema\nBy default, this package builds the zendesk staging models within a schema titled (`\u003ctarget_schema\u003e` + `_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:\n\n```yml\nmodels:\n    zendesk_source:\n      +schema: my_new_schema_name # leave blank for just the target_schema\n```\n    \n### Change the source table references (only if using a single connection)\nIf an individual source table has a different name than the package expects, add the table name as it appears in your destination to the respective variable. This is not available when running the package on multiple unioned connections.\n\u003e IMPORTANT: See this project's [dbt_project.yml](https://github.com/fivetran/dbt_zendesk_source/blob/main/dbt_project.yml) variable declarations to see the expected names.\n    \n```yml\nvars:\n    zendesk_\u003cdefault_source_table_name\u003e_identifier: your_table_name \n```\n\n#### Snowflake Users\nIf you do **not** use the default all-caps naming conventions for Snowflake, you may need to provide the case-sensitive spelling of your source tables that are also Snowflake reserved words.\n\nIn this package, this would apply to the `GROUP` source. If you are receiving errors for this source, include the below identifier in your `dbt_project.yml` file:\n\n```yml\nvars:\n    zendesk_group_identifier: \"Group\" # as an example, must include the double-quotes and correct case\n```  \n\n\u003c/details\u003e\n\n### (Optional) Step 6: Orchestrate your models with Fivetran Transformations for dbt Core™\n\u003cdetails\u003e\u003csummary\u003eExpand to view details\u003c/summary\u003e\n\u003cbr\u003e\n    \nFivetran offers the ability for you to orchestrate your dbt project through [Fivetran Transformations for dbt Core™](https://fivetran.com/docs/transformations/dbt). Learn how to set up your project for orchestration through Fivetran in our [Transformations for dbt Core™ setup guides](https://fivetran.com/docs/transformations/dbt#setupguide).\n\u003c/details\u003e\n    \n## Does this package have dependencies?\nThis dbt package is dependent on the following dbt packages. These dependencies are installed by default within this package. For more information on the following packages, refer to the [dbt hub](https://hub.getdbt.com/) site.\n\u003e IMPORTANT: If you have any of these dependent packages in your own `packages.yml` file, we highly recommend that you remove them from your root `packages.yml` to avoid package version conflicts.\n```yml\npackages:\n    - package: fivetran/fivetran_utils\n      version: [\"\u003e=0.4.0\", \"\u003c0.5.0\"]\n\n    - package: dbt-labs/dbt_utils\n      version: [\"\u003e=1.0.0\", \"\u003c2.0.0\"]\n\n    - package: dbt-labs/spark_utils\n      version: [\"\u003e=0.3.0\", \"\u003c0.4.0\"]\n```\n          \n## How is this package maintained and can I contribute?\n### Package Maintenance\nThe Fivetran team maintaining this package _only_ maintains the latest version of the package. We highly recommend that you stay consistent with the [latest version](https://hub.getdbt.com/fivetran/zendesk_source/latest/) of the package and refer to the [CHANGELOG](https://github.com/fivetran/dbt_zendesk_source/blob/main/CHANGELOG.md) and release notes for more information on changes across versions.\n\n### Contributions\nA small team of analytics engineers at Fivetran develops these dbt packages. However, the packages are made better by community contributions.\n\nWe highly encourage and welcome contributions to this package. Check out [this dbt Discourse article](https://discourse.getdbt.com/t/contributing-to-a-dbt-package/657) to learn how to contribute to a dbt package.\n\n## Are there any resources available?\n- If you have questions or want to reach out for help, see the [GitHub Issue](https://github.com/fivetran/dbt_zendesk_source/issues/new/choose) section to find the right avenue of support for you.\n- If you would like to provide feedback to the dbt package team at Fivetran or would like to request a new dbt package, fill out our [Feedback Form](https://www.surveymonkey.com/r/DQ7K7WW).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffivetran%2Fdbt_zendesk_source","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffivetran%2Fdbt_zendesk_source","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffivetran%2Fdbt_zendesk_source/lists"}