{"id":22793276,"url":"https://github.com/fivetran/dbt_amplitude","last_synced_at":"2025-04-16T18:49:16.816Z","repository":{"id":60749898,"uuid":"529337428","full_name":"fivetran/dbt_amplitude","owner":"fivetran","description":"Fivetran's Amplitude dbt package","archived":false,"fork":false,"pushed_at":"2025-02-26T17:47:56.000Z","size":1601,"stargazers_count":3,"open_issues_count":2,"forks_count":3,"subscribers_count":34,"default_branch":"main","last_synced_at":"2025-03-29T05:33:44.714Z","etag":null,"topics":["amplitude","dbt","dbt-packages","fivetran","fivetran-product-analytics-reporting","product-analytics"],"latest_commit_sha":null,"homepage":"https://fivetran.github.io/dbt_amplitude/","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":"2022-08-26T16:51:31.000Z","updated_at":"2025-02-26T17:51:03.000Z","dependencies_parsed_at":"2023-02-18T01:01:39.761Z","dependency_job_id":"542538f7-c473-4e1e-9d7d-d21b5b906c44","html_url":"https://github.com/fivetran/dbt_amplitude","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fivetran%2Fdbt_amplitude","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fivetran%2Fdbt_amplitude/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fivetran%2Fdbt_amplitude/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fivetran%2Fdbt_amplitude/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fivetran","download_url":"https://codeload.github.com/fivetran/dbt_amplitude/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249266497,"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":["amplitude","dbt","dbt-packages","fivetran","fivetran-product-analytics-reporting","product-analytics"],"created_at":"2024-12-12T03:18:58.640Z","updated_at":"2025-04-16T18:49:16.809Z","avatar_url":"https://github.com/fivetran.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Amplitude Modeling dbt Package ([Docs](https://fivetran.github.io/dbt_amplitude/))\n\n\u003cp align=\"left\"\u003e\n    \u003ca alt=\"License\"\n        href=\"https://github.com/fivetran/dbt_amplitude/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\u003c/p\u003e\n\n## What does this dbt package do?\n- Produces modeled tables that leverage Amplitude data from [Fivetran's connector](https://fivetran.com/docs/applications/amplitude) in the format described by [this ERD](https://fivetran.com/docs/applications/amplitude#schemainformation) and builds off the output of our [Amplitude source package](https://github.com/fivetran/dbt_amplitude_source).\n\n- Enables users to do the following:\n  - Leverage event data that is enhanced with additional event type and pivoted custom property fields for later downstream use\n  - View aggregated metrics for each unique session\n  - View aggregated metrics for each unique user\n  - View daily performance metrics for each event type\n  - Use the enhanced event data to leverage dbt metrics to generate additional analytics\n  - Incorporate the [dbt Product Analytics](https://github.com/mjirv/dbt_product_analytics) package to further enhance Amplitude data, like for funnel and retention analysis\n\n\u003c!--section=\"amplitude_transformation_model\"--\u003e\nThis package also generates a comprehensive data dictionary of your source and modeled Amplitude data through the [dbt docs site](https://fivetran.github.io/dbt_amplitude/). You can also refer to the table below for a detailed view of all tables materialized within this package by default.\n\n|**Table**|**Description**\n-----|-----\n| [amplitude__event_enhanced](https://fivetran.github.io/dbt_amplitude/#!/model/model.amplitude.amplitude__event_enhanced)     | Each record represents event data, enhanced with event type data and unnested event, group, and user properties.\n| [amplitude__sessions](https://fivetran.github.io/dbt_amplitude/#!/model/model.amplitude.amplitude__sessions)         | Each record represents a distinct session with aggregated metrics for that session.\n| [amplitude__user_enhanced](https://fivetran.github.io/dbt_amplitude/#!/model/model.amplitude.amplitude__user_enhanced)               | Each record represents a distinct user with aggregated metrics for that user.\n| [amplitude__daily_performance](https://fivetran.github.io/dbt_amplitude/#!/model/model.amplitude.amplitude__daily_performance)               | Each record represents performance metrics for each distinct day and event type.\n\n### Materialized Models\nEach Quickstart transformation job run materializes 8 models if all components of this data model are enabled. This count includes all staging, intermediate, and final models materialized as `view`, `table`, or `incremental`.\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- At least one Fivetran Amplitude 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 must add the following (or a variation of the following) dispatch configuration within your `dbt_project.yml` file. 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### Database Incremental Strategies\nThis package's incremental models are configured to leverage the different incremental strategies for each supported warehouse.\n\nFor **BigQuery** and **Databricks All Purpose Cluster runtime** destinations, we have chosen insert_overwrite as the default strategy, which benefits from the partitioning capability. \n\u003e For **Databricks SQL Warehouse** destinations, models are materialized as tables without support for incremental runs.\n\nFor **Snowflake**, **Redshift**, and **Postgres** databases, we have chosen delete+insert as the default strategy.  \n\n\u003e Regardless of strategy, we recommend that users periodically run a --full-refresh to ensure a high level of data quality.\n\n### Step 2: Install the package\nInclude the following Amplitude package version in your `packages.yml` file:\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/amplitude\n    version: [\"\u003e=0.6.0\", \"\u003c0.7.0\"]\n```\n\nDo NOT include the `amplitude_source` package in this file. The transformation package itself has a dependency on it and will install the source package as well.\n\n### Step 3: Define database and schema variables\nBy default, this package will run using your target database and the `amplitude` schema. If this is not where your Amplitude data is, add the following configuration to your root `dbt_project.yml` file:\n\n```yml\n# dbt_project.yml\n\n...\nconfig-version: 2\n\nvars:\n    amplitude_database: your_database_name    \n    amplitude_schema: your_schema_name\n```\n### Step 4: Configure event date range\nBecause of the typical volume of event data, you may want to limit this package's models to work with a recent date range. \n\nThe default date range starts at `'2020-01-01'` and extends up to and including the current date for the [`stg_amplitude__event`](https://github.com/fivetran/dbt_amplitude_source/blob/main/models/stg_amplitude__event.sql) and [`date spine`](https://github.com/fivetran/dbt_amplitude/blob/main/models/intermediate/int_amplitude__date_spine.sql) models. To customize the date range, add the following configurations to your root `dbt_project.yml` file:\n\n```yml\nvars:\n    amplitude__date_range_start: '2022-01-01' # your start date here\n    amplitude__date_range_end: '2022-12-01' # your end date here\n```\nNOTE: The `amplitude__daily_performance`, `amplitude__event_enhanced`, and `amplitude__sessions` models are materialized as incremental. Updating the date range in `dbt_project.yml` will only apply to newly ingested data. If you modify the date range variables, we recommend running `dbt run --full-refresh` to ensure consistency across the adjusted date range.\n\n### (Optional) Step 5: Additional configurations\n\u003cdetails open\u003e\u003csummary\u003eExpand/collapse configurations\u003c/summary\u003e\n\n#### Lookback Window\nRecords from the source can sometimes arrive late. Since several of the models in this package are incremental, by default we look back 3 days from new records to ensure late arrivals are captured and avoiding the need for frequent full refreshes. While the frequency can be reduced, we still recommend running `dbt --full-refresh` periodically to maintain data quality of the models. \n\nTo change the default lookback window, add the following variable to your `dbt_project.yml` file:\n\n```yml\nvars:\n  amplitude:\n    lookback_window: number_of_days # default is 3\n```\n\n#### Change source table references\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:\n\u003e IMPORTANT: See the package's source [`dbt_project.yml`](https://github.com/fivetran/dbt_amplitude_source/blob/main/dbt_project.yml) variable declarations to see the expected names.\n\n```yml\nvars:\n    \u003cpackage_name\u003e__\u003cdefault_source_table_name\u003e_identifier: your_table_name\n```\n\n#### Change build schema\nBy default, this package builds the GitHub staging models within a schema titled (\u003ctarget_schema\u003e + `_stg_amplitude`) in your target database. If this is not where you would like your GitHub staging data to be written to, add the following configuration to your root `dbt_project.yml` file:\n\n```yml\n# dbt_project.yml\nmodels:\n    amplitude_source:\n      +schema: my_new_schema_name # leave blank for just the target_schema\n```\n#### Pivot out nested fields containing custom properties\nThe Amplitude schema allows for custom properties to be passed as nested fields (for example, `user_properties: {\"Cohort\":\"Test A\"}`). To pivot out the properties, add the following configurations to your root `dbt_project.yml` file:\n\n```yml\nvars:\n    event_properties_to_pivot: ['event_property_1','event_property_2']\n    group_properties_to_pivot: ['group_property_1','group_property_2']\n    user_properties_to_pivot: ['user_property_1','user_property_2']\n```\n\u003c/details\u003e\n\u003cbr\u003e\n\n### (Optional) Step 6: Using this package with the dbt Product Analytics package\n\u003cdetails\u003e\u003csummary\u003eExpand for configurations\u003c/summary\u003e\n\nThe [dbt_product_analytics](https://github.com/mjirv/dbt_product_analytics) package contains macros that allows for further exploration such as event flow, funnel, and retention analysis. To leverage this in conjunction with this package, add the following configuration to your project's `packages.yml` file:\n```yml\npackages:\n  - package: mjirv/dbt_product_analytics\n    version: [\"\u003e=0.1.0\"]\n```\n\nRefer to the [dbt_product_analytics](https://github.com/mjirv/dbt_product_analytics) usage instructions and the example below:\n```sql\n-- # product_analytics_funnel.sql\n{% set events =\n  dbt_product_analytics.event_stream(\n    from=ref('amplitude__event_enhanced'),\n    event_type_col=\"event_type\",\n    user_id_col=\"amplitude_user_id\",\n    date_col=\"event_day\",\n    start_date=\"your_start_date\",\n    end_date=\"your_end_date\")\n%}\n\n{% set steps = [\"event_type_1\", \"event_type_2\", \"event_type_3\"] %}\n\n{{ dbt_product_analytics.funnel(steps=steps, event_stream=events) }}\n\n```\n\n\u003c/details\u003e\n\u003cbr\u003e\n\n### (Optional) Step 7: Orchestrate your models with Fivetran Transformations for dbt Core™\n\u003cdetails\u003e\u003csummary\u003eExpand for details\u003c/summary\u003e\n\u003cbr\u003e\n\nFivetran offers the ability for you to orchestrate your dbt project through the [Fivetran Transformations for dbt Core™](https://fivetran.com/docs/transformations/dbt) product. Refer to the linked docs for more information on how to setup your project for orchestration through Fivetran.\n\n\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/amplitude_source\n      version: [\"\u003e=0.4.0\", \"\u003c0.5.0\"]\n\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## 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 you stay consistent with the [latest version](https://hub.getdbt.com/fivetran/amplitude/latest/) of the package and refer to the [CHANGELOG](https://github.com/fivetran/dbt_amplitude/blob/main/CHANGELOG.md) and release notes for more information on changes across versions.\n\n### Opinionated Decisions\nIn creating this package, which is meant for a wide range of use cases, we had to take opinionated stances on a few different questions we came across during development. We've consolidated significant choices we made in the [DECISIONLOG.md](https://github.com/fivetran/dbt_amplitude/blob/main/DECISIONLOG.md), and will continue to update as the package evolves. We are always open to and encourage feedback on these choices, and the package in general.\n\n### Contributions\nThese dbt packages are developed by a small team of analytics engineers at Fivetran. However, the packages are made better by community contributions.\n\nWe highly encourage and welcome contributions to this package. Check out [this post](https://discourse.getdbt.com/t/contributing-to-a-dbt-package/657) on the best workflow for contributing to a package.\n\n## Are there any resources available?\n- If you encounter any questions or want to reach out for help, see the [GitHub Issue](https://github.com/fivetran/dbt_amplitude/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 future dbt package to be developed, then feel free to 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_amplitude","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffivetran%2Fdbt_amplitude","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffivetran%2Fdbt_amplitude/lists"}