{"id":18419647,"url":"https://github.com/teradata/dbt-teradata-utils","last_synced_at":"2025-10-11T08:11:53.640Z","repository":{"id":146377784,"uuid":"454507437","full_name":"Teradata/dbt-teradata-utils","owner":"Teradata","description":"Teradata package that provides compatibility for dbt-utils","archived":false,"fork":false,"pushed_at":"2024-09-24T08:50:17.000Z","size":107,"stargazers_count":3,"open_issues_count":1,"forks_count":5,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-03-22T19:11:50.519Z","etag":null,"topics":["dbt","elt","sql","teradata","warehouses"],"latest_commit_sha":null,"homepage":"","language":"Makefile","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/Teradata.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-02-01T18:39:36.000Z","updated_at":"2024-09-24T08:49:29.000Z","dependencies_parsed_at":null,"dependency_job_id":"6e43a9e8-38b9-4657-a542-38a976fb3ff0","html_url":"https://github.com/Teradata/dbt-teradata-utils","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/Teradata%2Fdbt-teradata-utils","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Teradata%2Fdbt-teradata-utils/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Teradata%2Fdbt-teradata-utils/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Teradata%2Fdbt-teradata-utils/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Teradata","download_url":"https://codeload.github.com/Teradata/dbt-teradata-utils/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247661755,"owners_count":20975111,"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","elt","sql","teradata","warehouses"],"created_at":"2024-11-06T04:17:44.854Z","updated_at":"2025-10-11T08:11:48.607Z","avatar_url":"https://github.com/Teradata.png","language":"Makefile","readme":"# dbt package `teradata_utils`\n\nThis [dbt](https://github.com/dbt-labs/dbt) package provides compatibility with `dbt_utils` package for Teradata Vantage.\n\n## Installation Instructions\n\n1. Add the package as a dependency to your project in `packages.yml`:\n    ```\n    packages:\n    - package: Teradata/teradata_utils\n      version: 1.3.0\n    ```\n    For more information about installing packages, see [dbt documentation](https://docs.getdbt.com/docs/package-management).\n1. Set the `dispatch` config in your root project (on dbt v0.20.0 and newer) and let `teradata_utils` package intercept macros from the `dbt_utils` namespace:\n    ```\n    dispatch:\n      - macro_namespace: dbt_utils\n        search_order: ['teradata_utils', 'dbt_utils']\n    ```\n\n### Additional steps for `surrogate_key` macro\n\n`surrogate_key` macro needs an `md5` function implementation. Teradata doesn't support `md5` natively. You need to install a User Defined Function (UDF):\n1. Download the md5 UDF implementation from Teradata (registration required): https://downloads.teradata.com/download/extensibility/md5-message-digest-udf.\n1. Unzip the package and go to `src` directory.\n1. Start up `bteq` and connect to your database.\n1. Create database `GLOBAL_FUNCTIONS` that will host the UDF. You can't change the database name as it's hardcoded in the macro:\n    ```sql\n    CREATE DATABASE GLOBAL_FUNCTIONS AS PERMANENT = 60e6, SPOOL = 120e6;\n    ```\n1. Create the UDF. Replace `\u003cCURRENT_USER\u003e` with your current database user:\n    ```sql\n    GRANT CREATE FUNCTION ON GLOBAL_FUNCTIONS TO \u003cCURRENT_USER\u003e;\n    DATABASE GLOBAL_FUNCTIONS;\n    .run file = hash_md5.btq\n    ```\n1. Grant permissions to run the UDF to your dbt user. Replace `\u003cDBT_USER\u003e` with the user id you use in dbt:\n    ```sql\n    GRANT EXECUTE FUNCTION ON GLOBAL_FUNCTIONS TO \u003cDBT_USER\u003e;\n    ```\n\n## Compatibility\n\n\n|     Macro Group       |           Macro Name          |         Status        |                                 Comment                                |\n|:---------------------:|:-----------------------------:|:---------------------:|:----------------------------------------------------------------------:|\n| Schema tests          | equal_rowcount                | :white_check_mark:    | no customization needed                                                |\n| Schema tests          | fewer_rows_than               | :white_check_mark:    | custom macro provided                                                  |\n| Schema tests          | equality                      | :white_check_mark:    | no customization needed                                                |\n| Schema tests          | expression_is_true            | :white_check_mark:    | no customization needed                                                |\n| Schema tests          | recency                       | :white_check_mark:    | custom macro provided                                                  |\n| Schema tests          | at_least_one                  | :white_check_mark:    | no customization needed                                                |\n| Schema tests          | not_constant                  | :white_check_mark:    | no customization needed                                                |\n| Schema tests          | cardinality_equality          | :white_check_mark:    | no customization needed                                                |\n| Schema tests          | unique_where                  |        :x:            | no longer supported by dbt-utils, use built-in `unique` test instead   |\n| Schema tests          | not_null_where                |        :x:            | no longer supported by dbt-utils, use built-in `not_null` test instead |\n| Schema tests          | not_null_proportion           | :white_check_mark:    | custom macro provided                                                  |\n| Schema tests          | not_accepted_values           | :white_check_mark:    | no customization needed                                                |\n| Schema tests          | relationships_where           | :white_check_mark:    | no customization needed                                                |\n| Schema tests          | mutually_exclusive_ranges     | :white_check_mark:    | custom macro provided                                                  |\n| Schema tests          | sequential_values             | :white_check_mark:    | no customization needed                                                |\n| Schema tests          | unique_combination_of_columns | :white_check_mark:    | no customization needed                                                |\n| Schema tests          | accepted_range                | :white_check_mark:    | no customization needed                                                |\n| Schema tests          | at_least_one                | :white_check_mark:    |  custom macro provided                                               |\n| Schema tests          | expression_is_true             | :white_check_mark:    |  custom macro provided                                               |\n| Introspective macros  | get_column_values             | :white_check_mark:    | custom macro provided                                                  |\n| Introspective macros  | get_relations_by_pattern      | :white_check_mark:    | custom macro provided                                                  |\n| Introspective macros  | get_relations_by_prefix       | :white_check_mark:    | custom macro provided                                                  |\n| Introspective macros  | get_query_results_as_dict     | :white_check_mark:    | custom macro provided                                                  |\n| SQL generators        | date_spine                    | :white_check_mark:    | custom macro provided                                                  |\n| SQL generators        | haversine_distance            | :white_check_mark:    | no customization needed                                                |\n| SQL generators        | group_by                      | :white_check_mark:    | no customization needed                                                |\n| SQL generators        | star                          | :white_check_mark:    | no customization needed                                                |\n| SQL generators        | union_relations               | :white_check_mark:    | custom macro provided                                                  |\n| SQL generators        | generate_series               | :white_check_mark:    | custom macro provided                                                  |\n| SQL generators        | generate_surrogate_key             | :white_check_mark:    | custom macro provided, [additional install steps required](#additional-steps-for-surrogate_key-macro)               |\n| SQL generators        | safe_add                      | :white_check_mark:    | no customization needed                                                |\n| SQL generators        | pivot                         | :white_check_mark:    | no customization needed                                                |\n| SQL generators        | unpivot                       | :white_check_mark:    | no customization needed, see [compatibility note](#unpivot)            |\n| SQL generators        | deduplicate                        | :white_check_mark:    | custom macro provided                                                |\n| Web macros            | get_url_parameter             | :white_check_mark:    | no customization needed                                                |\n| Web macros            | get_url_host                  | :white_check_mark:    | no customization needed                                                |\n| Web macros            | get_url_path                  | :white_check_mark:    | custom macro provided                                                  |\n| Cross-database macros | current_timestamp             | :white_check_mark:    | custom macro provided                                                  |\n| Cross-database macros | dateadd                       | :white_check_mark:    | custom macro provided                                                  |\n| Cross-database macros | datediff                      | :white_check_mark:    | custom macro provided                                                  |\n| Cross-database macros | split_part                    | :white_check_mark:    | custom macro provided                                                  |\n| Cross-database macros | date_trunc                    | :white_check_mark:    | custom macro provided                                                  |\n| Cross-database macros | last_day                      | :white_check_mark:    | no customization needed, see [compatibility note](#last_day)           |\n| Cross-database macros | width_bucket                  | :white_check_mark:    | no customization needed                                                |\n| Jinja Helpers         | pretty_time                   | :white_check_mark:    | no customization needed                                                |\n| Jinja Helpers         | pretty_log_format             | :white_check_mark:    | no customization needed                                                |\n| Jinja Helpers         | log_info                      | :white_check_mark:    | no customization needed                                                |\n| Jinja Helpers         | slugify                       | :white_check_mark:    | no customization needed                                                |\n| Materializations      | insert_by_period              | :white_check_mark:    | custom macro provided                                                  |\n\n\n### \u003ca name=\"unpivot\"\u003e\u003c/a\u003eunpivot\n\n`unpivot` uses `value` as the default name for the value column. `value` is a reserved word in Teradata. Make sure you specify a different value in `value_name` parameter, e.g.:\n```\n{{ \n  dbt_utils.unpivot(\n    relation=ref('table_name'),\n    cast_to='datatype',\n    exclude=[\u003clist of columns to exclude from unpivot\u003e],\n    remove=[\u003clist of columns to remove\u003e],\n    field_name=\u003ccolumn name for field\u003e,\n    value_name='_value'\n  ) \n}}\n```\n\n### \u003ca name=\"last_day\"\u003e\u003c/a\u003elast_day\n\n`last_day` in `teradata_utils`, unlike the corresponding macro in `dbt_utils`, doesn't support `quarter` datepart.\n### Note to maintainers of other packages\n\nThe teradata-utils package may be able to provide compatibility for your package, especially if your package leverages dbt-utils macros for cross-database compatibility. This package _does not_ need to be specified as a dependency of your package in `packages.yml`. Instead, you should encourage anyone using your package on Teradata to:\n- Install `teradata_utils` alongside your package\n- Add a `dispatch` config in their root project, like the one above\n\n### Contributing\n\nWe welcome contributions to this repo! To contribute a new feature or a fix, please open a Pull Request with 1) your changes and 2) updated documentation for the `README.md` file.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fteradata%2Fdbt-teradata-utils","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fteradata%2Fdbt-teradata-utils","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fteradata%2Fdbt-teradata-utils/lists"}