dbt-trino
Introduction
dbt is a data transformation workflow tool that lets teams quickly and collaboratively deploy analytics code, following software engineering best practices like modularity, CI/CD, testing, and documentation. It enables anyone who knows SQL to build production-grade data pipelines.
One frequently asked question in the context of using dbt tool is:
Can I connect my dbt project to two databases?
(see the answered question on the dbt website).
TL;DR dbt stands for transformation as in T within ELT pipelines, it doesn't move data from source to a warehouse.
dbt-trino adapter uses Trino as a underlying query engine to perform query federation across disperse data sources. Trino connects to multiple and diverse data sources (available connectors) via one dbt connection and process SQL queries at scale. Transformations defined in dbt are passed to Trino which handles these SQL transformation queries and translates them to queries specific to the systems it connects to create tables or views and manipulate data.
This repository represents a fork of the dbt-presto with adaptations to make it work with Trino.
Compatibility
This dbt plugin has been tested against Trino version 478, Starburst Enterprise version 482-e.1 and Starburst Galaxy.
Setup & Configuration
For information on installing and configuring your profile to authenticate to Trino or Starburst, please refer to Starburst and Trino Setup in the dbt docs.
Trino- and Starburst-specific configuration
For Trino- and Starburst-specific configuration, you can refer to Starburst (Trino) configurations on the dbt docs site.
Query routing
client_tags and http_headers can be set per model, for the statements that model runs: client_tags replaces the profile's list entirely, while http_headers is merged on top of the profile's, with the model's values winning on a name collision.
{{ config(materialized='table', client_tags=['fault-tolerant']) }}
Trino routers pick a cluster per statement from the request headers, so this lets a single dbt run send individual models to different clusters - a large incremental model to a fault-tolerant cluster, say, while the rest of the project stays on the default one. With Starburst Galaxy the routing decision is made from the client tags and the user's role.
Two things to keep in mind:
- A query whose tags match no routing rule is rejected, not sent to a default cluster (unless a default routing rule is configured). Give your profile tags that match a rule, since statements dbt runs outside a model - metadata queries, for instance - use the profile's. This includes dbt's own pre-run bookkeeping, such as listing and creating schemas and populating the relation cache for every database and schema touched by the run: those queries run once up front, before any model executes and without any per-model context, so they can never pick up a model's
client_tags/http_headers- only your profile's. X-Trino-Client-Tagscannot be set throughhttp_headers; Trino builds that header itself fromclient_tags.- A model's tests are separate nodes with their own config, so they do not inherit the model's
client_tags/http_headersand run with the profile's instead. Configure routing on the tests themselves - inline on each test'sconfig, or path-scoped undertests:/data_tests:indbt_project.yml- if they need to reach the same cluster as the model.
Contributing
- Want to report a bug or request a feature? Let us know on Slack in the #db-starburst-and-trino channel, or on Trino slack in the #python channel, or open an issue
- Want to help us build dbt-trino? Check out the Contributing Guide
Release process
First 5 steps are ONLY relevant for bumping minor version:
- Create
1.x.latestbranch from the latest tag corresponding to current minor version, e.g.git checkout -b 1.6.latest v1.6.2(when bumping to 1.7). Push branch to remote. This branch will be used for potential backports. - Create new branch (Do not push below commits to
1.x.latest). Add a new entry in.changes/0.0.0.mdthat points to the newly created latest branch. - Run
changie mergeto updateREADME.md. After that, remove changie files and folders related to current minor version. Commit. - Bump version of
dbt-tests-adapter. Commit. - Merge these 2 commits into the master branch. Add a
Skip Changleloglabel to the PR.
Continue with the next steps for a minor version bump. Start from this point for a patch version bump:
- Run
Version Bumpworkflow. The major and minor part of the dbt version are used to associate dbt-trino's version with the dbt version. - Merge the bump PR. Make sure that test suite pass.
- Run
dbt-trino releaseworkflow to releasedbt-trinoto PyPi and GitHub.
Backport process
Sometimes it is necessary to backport some changes to some older versions. In that case, create branch from x.x.latest branch. There is a x.x.latest for each minor version, e.g. 1.3.latest. Make a fix and open PR back to x.x.latest. Create changelog by changie new as ususal, as separate changlog for each minor version is kept on every x.x.latest branch.
After merging, to make a release of that version, just follow instructions from Release process section, but run every workflow on x.x.latest branch.
Code of Conduct
Everyone interacting in the dbt project's codebases, issue trackers, chat rooms, and mailing lists is expected to follow the PyPA Code of Conduct.
Release files for dbt-trino 1.10.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| dbt_trino-1.10.4.tar.gz | 42.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| dbt_trino-1.10.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 92.4 kB
Release files / dbt_trino-1.10.4.tar.gz
| Download URL | dbt_trino-1.10.4.tar.gz |
|---|---|
| Size | 42.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2571975ec51afb6de542bc634f924d6f285136c34fc9fe62417a179e726e6dff
|
|
BLAKE2b-256 checksum How to use checksums |
d9714003baa9d824c981875dc2593f7a16b3d7721312a47f98daae7b13255370
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.15
|
Release files / dbt_trino-1.10.4-py3-none-any.whl
| Download URL | dbt_trino-1.10.4-py3-none-any.whl |
|---|---|
| Size | 50.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b6bc5460e8140669ad550cc20f54fe94aa7931908ada9617eb6d2029dffc5f55
|
|
BLAKE2b-256 checksum How to use checksums |
c360941cbbf741d176a0383a24c5063a3ac4e99802a2568d6eb0b1eca84c6474
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.15
|