Skip to content

Latest commit

 

History

History
67 lines (52 loc) · 2.52 KB

README.md

File metadata and controls

67 lines (52 loc) · 2.52 KB

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}"