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
This package provides "shims" for:
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.
To make use of these trino adaptations in your dbt project, you must do two things:
- Install both
trino_utils
and any of the compatible packages listed above by adding them to yourpackages.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}
- Tell the supported package to also look for the
trino_utils
macros by adding the relevantdispatches
to yourdbt_project.yml
dispatch: - macro_namespace: dbt_utils search_order: ['trino_utils', 'dbt_utils'] - macro_namespace: dbt_date search_order: ['trino_utils', 'dbt_date'] - macro_namespace: metrics search_order: ['trino_utils', 'metrics']
Check dbt Hub for the latest installation instructions, or read the docs for more information on installing packages.
If new version of dbt-utils is released, and you want to use it, update instruction below. Remember to always point HEAD to certain tag in this submodule, never leave HEAD pointing to any branch.
cd dbt-utils
go to dbt-utils submodule directorygit switch main
switch to main branchgit fetch --tags
fetch tags from dbt-utils remotegit switch 1.0.0 --detach
switch to tag with certain version to which you want upgrade, here 1.0.0 for examplecd ..
go to dbt-trino-utils top directory. Commit, push this change to dbt-trino-utils remote.
- Create a release of github repository. Use semantic versioning to give an appriopiate version number. Don't try to match dbt-utils version number, as at some point these versions' numbers won't be equal anyway, that's inevitable. Just follow semantic versioning. Remember to add appropriate release notes (changelog, contributors).
- Wait for adding your new release to dbt Hub. It is done automatically by dbt-labs script Hubcap. Check on trino_utils package site if new version is available. It should happen within one business day.
- Announce new release on dbt slack, at db-presto-trino channel.
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}"