{"id":31892651,"url":"https://github.com/versent/dbt_versent_dimensional_automate","last_synced_at":"2026-02-27T04:33:48.357Z","repository":{"id":311867037,"uuid":"926345770","full_name":"Versent/dbt_versent_dimensional_automate","owner":"Versent","description":null,"archived":false,"fork":false,"pushed_at":"2025-09-09T00:48:16.000Z","size":101,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-09T02:56:41.969Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"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/Versent.png","metadata":{"files":{"readme":"README.md","changelog":null,"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,"zenodo":null}},"created_at":"2025-02-03T04:39:11.000Z","updated_at":"2025-08-28T07:11:45.000Z","dependencies_parsed_at":"2025-08-27T12:54:16.584Z","dependency_job_id":"258bb036-346f-4a62-868b-91d6cbc6049b","html_url":"https://github.com/Versent/dbt_versent_dimensional_automate","commit_stats":null,"previous_names":["versent/versent_automate_dbt_dimensional"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/Versent/dbt_versent_dimensional_automate","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Versent%2Fdbt_versent_dimensional_automate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Versent%2Fdbt_versent_dimensional_automate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Versent%2Fdbt_versent_dimensional_automate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Versent%2Fdbt_versent_dimensional_automate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Versent","download_url":"https://codeload.github.com/Versent/dbt_versent_dimensional_automate/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Versent%2Fdbt_versent_dimensional_automate/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279014308,"owners_count":26085493,"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","status":"online","status_checked_at":"2025-10-13T02:00:06.723Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2025-10-13T08:58:36.213Z","updated_at":"2025-10-13T08:58:37.840Z","avatar_url":"https://github.com/Versent.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Dimensional Model Automation Macros by Versent\n\nStreamline Your Dimensional Modeling with Automation! \nThis package provides dbt macros that automate the creation of dimensional models, \nincluding Type 1 and Type 2 Slowly Changing Dimensions (SCDs) and fact tables. By leveraging these macros, you can streamline \nyour data modeling process while maintaining data integrity, historical accuracy, and consistency across your dbt projects.\n\nWhat does this package offer?\n -  Increased Productivity - Automates the creation of Type 1 \u0026 Type 2 dimensions and fact tables, reducing manual effort.\n -  Data Integrity \u0026 Historical Tracking - Ensures accurate Type 2 tracking with effective and expiration dates.\n -  Consistency Across Models - Standardized implementation of dimensions and facts simplifies data pipelines.\n -  Seamless Integration with dbt - Uses dbt's built-in features for version control, documentation, and testing.\n -  Scalability - Designed to handle large datasets efficiently while supporting multi-threaded execution.\npuyt a change here\n\n## Installation\ndbt version required: \u003e=1.0.0, \u003c2.0.0\n\nInclude the following in your packages.yml file:\n\n```bash\npackages:\n  - git: \"https://{{env_var('DBT_ENV_SECRET_GIT_CREDENTIAL')}}@github.com/Versent/dbt_versent_dimensional_automate.git\"\n```\n\nRun dbt deps to install the package.\n\n## Table of Contents\n- [dim Macro (Type 1 or Type 2)](#dim-macro-type-1-or-type-2)\n- [fact](#fact-macro)\n\n## dim Macro (Type 1 or Type 2)\n\nThis macro creates either a Type 1 or Type 2 dimension table:\n\n- Type 1 dimensions always contain the latest record for each business key.\n- Type 2 dimensions track changes in attributes over time with effective and expiration dates.\n\nKey Benefits:\n\n- Eliminates the need for manually coding SCD logic.\n- Supports both business key-based and role-playing dimensions.\n- Adds audit columns (record_source, load_datetime, etc.) for improved data governance.\n\nParameters:\n - name (string): The name of the dimension table.\n - source (string): The name of the source model.\n - payload (list): The list of columns to include in the dimension.\n - type2 (list): The list of columns for Type 2 tracking. Requires at least the as_of_date column name.\n\nOutput:\n- Type 1: A dimension table containing the latest attribute values, with audit columns such as record_source and load_datetime.\n- Type 2: A dimension table with effective_from_datetime, effective_to_datetime, and an is_current flag.\n\n\nExample Macro Invocation:\n\n```bash\n\n# Provide metadata\n{%- set yaml_metadata -%}\nname: customer\nsource: __int_dim_type_II__template\npayload:\n    - first_name\n    - last_name\n    - first_order_date\n    - most_recent_order_date\n    - number_of_orders\n    - lifetime_value\ntype2:\n    as_of_date: as_of_date\n{%- endset -%}\n{% set metadata_dict = fromyaml(yaml_metadata) %}\n\n# Call the macro\n{{ dbt_versent_dimensional_automate.dim(\n    name    = metadata_dict['name'],\n    source  = metadata_dict['source'],\n    payload = metadata_dict['payload'],\n    type2   = metadata_dict['type2']\n    ) \n}}\n\n```\n\n\n## fact Macro\n\nThis macro automates fact table creation by linking Type 1 and Type 2 dimensions. \nIt generates a fact table with Type 2 dimension support, ensuring that each fact row correctly aligns with dimension changes.\n\nKey Benefits:\n\n- Simplifies fact table design by automatically integrating Type 1 \u0026 Type 2 dimensions.\n- Ensures historical accuracy by aligning facts with the correct dimensional state.\n- Supports role-playing dimensions (e.g., Order Date vs. Delivery Date).\n\nParameters:\n - source (string): The source model.\n - name (string): The name of the fact table.\n - primary_key (string): The name of the primary key column.\n - type1_dimensions (list): A list of Type 1 dimensions.\n    - question (string) - Represents the business question that this dimension answers.\n    - join_key (string) - Primary Key used to join the fact table to the dimension.\n    - role_playing (dictionary, optional) = Specifies role-playing columns for dimension that server multiple contextual roles in\n                                            in the fact table\n - type2_dimensions (list): A list of Type 2 dimensions.\n - payload (list): A list of measure columns.\n\nOutput:\nA fact table with proper dimension keys and measures.\n\nExample Macro Invocation:\n\n```bash\n\n# Provide metadata\n{%- set yaml_metadata -%}\nsource:             __int_fact__template\nname:               sales_order\nprimary_key:        bk_sales_order\n\n# dimensions\ntype1:\n    dimensions:\n        - date:\n            question: when\n            join_key: bk_date\n            role_playing:\n                order_date:     \n                delivery_date:\ntype2:\n    dimensions:\n        - customer:\n            question: who\n            join_key: bk_customer\n        - product:\n            question: what\n            join_key: bk_product\n            role_playing:\n                manufacturing_product:    \n    dimension_as_of_date: load_datetime  \n       \npayload:\n    - quantity_sold\n    - total_sales_amount\n    - discount_amount\n    - tax_amount   \n\n{%- endset -%}\n{% set metadata_dict = fromyaml(yaml_metadata) %}\n\n# Call the macro\n{{ fact(\n    source = metadata_dict['source'],\n    name = metadata_dict['name'],\n    primary_key = metadata_dict['primary_key'],\n    type1_dims = metadata_dict['type1'],\n    type2_dims = metadata_dict['type2'],\n    payload = metadata_dict['payload'],\n) }}\n```\n\n## Example Templates\nWe provide example models to demonstrate how to use the macros in this package.\nThese are stored under  **models/templates/** .\n\nEach template includes a config(enabled = False) flag by default, so they are not built automatically when the package is installed.\n\n### How to Use the Templates\n1. Navigate to the **models/templates/** directory.\n2. Open the desired template and change the value of **enabled** in the config block at the top of the file to **True** as shown below:\n```bash\n{{ config(\n    enabled = True\n    ) }}\n```\n3. Run dbt build to test it.\n\n### Notes on Dependencies\nTemplates prefixed with **_dim___** or **_fact___** depend on an **_int___** (intermediate) model as their source.\nMake sure to build the corresponding  **_int___**  model first, since it provides the raw data required by the dimension or fact template.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fversent%2Fdbt_versent_dimensional_automate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fversent%2Fdbt_versent_dimensional_automate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fversent%2Fdbt_versent_dimensional_automate/lists"}