dbt-trino
The dbt-trino adapter allows dbt (data build tool) to connect to Trino, a distributed SQL query engine. It enables analytics engineers to transform data across various data sources that Trino can access, leveraging dbt's capabilities for modularity, testing, and documentation. The current version is 1.10.1, and it typically releases new versions in alignment with `dbt-core` major and minor releases.
Warnings
- breaking Starting with dbt-core v1.8, users must explicitly install both `dbt-core` and `dbt-trino` (e.g., `pip install dbt-core dbt-trino`). Prior to v1.8, installing the adapter implicitly installed `dbt-core`, but this behavior changed to decouple core and adapter versions.
- gotcha Trino's SQL dialect can differ from other data warehouses, requiring query modifications. Common differences include function names (e.g., `IFF()` in Snowflake is `IF()` in Trino, `NVL()` is `COALESCE()`, `DATEADD()` is `DATE_ADD()`) and behavior of implicit type coercion. Direct `PIVOT` functionality is also generally not available in Trino SQL.
- gotcha The `merge` incremental strategy (used for upserts) relies on underlying Trino connector support for `MERGE` statements. Some Trino connectors have limited or no `MERGE` support, which can lead to errors.
- gotcha When using AWS Glue as a metastore with Trino, the `on_table_exists='rename'` configuration for table materialization is not supported and will result in a `NOT_SUPPORTED` error. Glue does not support table renames.
- gotcha When using OAuth2 authentication, users have reported `Error: header info didn't have x_token_server` after tokens expire. This indicates that automatic token refresh or re-prompting might not occur as expected, requiring manual intervention.
- deprecated dbt-core v1.10 introduces new deprecation warnings for custom inputs such as unrecognized resource properties, configurations, top-level keys in YAML files, duplicate YAML keys, and unexpected Jinja blocks. Projects migrating to v1.10 or later may encounter these warnings.
Install
-
pip install dbt-core dbt-trino -
pip install dbt-trino -
pip install 'trino[external-authentication-token-cache]' keyring
Imports
- dbt-trino
N/A (Adapter is configured via profiles.yml)
Quickstart
import os
# 1. Install dbt-trino (already covered in install instructions)
# pip install dbt-core dbt-trino
# 2. Initialize a dbt project (if you don't have one)
# dbt init my_trino_project
# 3. Configure your profiles.yml (usually in ~/.dbt/profiles.yml)
# Example profiles.yml content for a basic Trino connection:
# my_trino_project:
# target: dev
# outputs:
# dev:
# type: trino
# method: none # Or 'ldap', 'jwt', 'oauth', etc.
# user: admin
# password: "" # Required if method is ldap/kerberos, otherwise optional
# catalog: hive_catalog # Your Trino catalog (e.g., hive, iceberg)
# host: localhost
# port: 8080
# schema: default_schema # Your Trino schema (database)
# threads: 4
# http_scheme: http # or https
# For OAuth2, ensure 'trino[external-authentication-token-cache]' and 'keyring' are installed
# and set method: oauth in profiles.yml
# 4. Create a simple dbt model (e.g., models/my_model.sql)
# -- models/my_model.sql
# {{ config(materialized='view') }}
# SELECT
# 1 as id,
# 'hello' as message
#
# 5. Run your dbt models (execute in your terminal in the dbt project directory)
# dbt debug --target dev
# dbt run --target dev
# dbt test --target dev