Skip to content

Utility functions for dbt projects running on Trino

License

Notifications You must be signed in to change notification settings

damian3031/dbt-trino-utils

 
 

Repository files navigation

trino_utils

This dbt package contains macros that:

  • can be (re)used across dbt projects running on Trino or Starburst databases
  • define implementations of dispatched macros from other packages that can be used on Trino or Starburst databases

Compatibility

This package provides "shims" for:

Usage

Wherever a custom trino macro exists, dbt_utils adapter dispatch will pass to trino_utils. This means you can just do {{dbt_utils.hash('mycolumnname')}} just like your friends with Snowflake.

Installation Instructions

To make use of these trino adaptations in your dbt project, you must do two things:

  1. Install both trino_utils and any of the compatible packages listed above by adding them to your packages.yml
    packages:
      - package: dbt-labs/dbt_utils 
        version: {SEE DBT HUB FOR NEWEST VERSION}
      - package: starburstdata/trino_utils
        version: {SEE DBT HUB FOR NEWEST VERSION}
  2. Tell the supported package to also look for the trino_utils macros by adding the relevant dispatches to your dbt_project.yml
    dispatch:
      - macro_namespace: dbt_utils
        search_order: ['trino_utils', 'dbt_utils']

Check dbt Hub for the latest installation instructions, or read the docs for more information on installing packages.

trino_utils specific macros

Cleanup Macros

Some helper macros have been added to simplfy development database cleanup. Usage is as follows:

Drop all schemas for each prefix with the provided prefix list (dev and myschema being a sample prefixes):

dbt run-operation trino__drop_schemas_by_prefixes --args "{prefixes: ['dev', 'myschema']}"

Drop all schemas with the single provided prefix (dev being a sample prefix):

dbt run-operation trino__drop_schemas_by_prefixes --args "{prefixes: myschema}"

Drop a schema with a specific name (myschema_seed being a sample schema name used in the project):

dbt run-operation trino__drop_schema_by_name --args "{schema_name: myschema_seed}"

Drop any models that are no longer included in the project (dependent on the current target):

dbt run-operation trino__drop_old_relations

or for a dry run to preview dropped models:

dbt run-operation trino__drop_old_relations --args "{dry_run: true}"

About

Utility functions for dbt projects running on Trino

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Shell 65.0%
  • Dockerfile 22.0%
  • Makefile 13.0%