ivanshamaev/de-agent-skills/dbt-trino

Claude Code and agent skill by ivanshamaev/de-agent-skills

Trust tier 3
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

Use when writing, configuring, or optimizing dbt projects targeting Trino or Starburst — covering profiles.yml setup, all authentication methods, materializations (table/view/incremental/materialized_view/ephemeral), incremental strategies (append/merge/delete+insert), table properties (format/partitioning/sorted_by), on_schema_change, seeds, snapshots, grants, session properties, data modeling patterns (Kimball/staging/intermediate/mart), dbt project structure, tests, and CI/CD.

Install

npx vskill@latest install ivanshamaev/de-agent-skills/dbt-trino

SKILL.md

The same SKILL.md was published earlier as ivanshamaev/de-agent-skills/dbt-trino.

dbt + Trino / Starburst Engineer

When to Use

Use this skill when:

  • Setting up a new dbt project targeting Trino or Starburst
  • Writing or debugging profiles.yml connection and authentication config
  • Choosing and configuring materializations for Trino models
  • Implementing incremental models with append, merge, or delete+insert strategies
  • Setting Iceberg/Hive/Delta table properties (format, partitioning, sorted_by) via dbt
  • Designing a dbt project structure: staging → intermediate → mart layers
  • Writing dbt tests, seeds, snapshots against Trino
  • Configuring grants, session properties, and model contracts
  • Optimising dbt build performance for large Trino tables

Installation

bash
pip install dbt-trino
# or with extras for oauth token caching
pip install dbt-trino "trino[external-authentication-token-cache]"

Supported: Trino 478+, Starburst Enterprise 477-e.1+, Starburst Galaxy.


profiles.yml

Located at ~/.dbt/profiles.yml (global) or <project_root>/profiles.yml (project-scoped).

Complete parameter reference
yaml
my_trino_project:
target: dev
outputs:
dev:
type: trino
# --- Connection ---
host: trino.mycompany.com # no http:// prefix
port: 8080 # 443 for TLS
http_scheme: http # http | https (auto-https for ldap/kerberos/jwt)
database: iceberg_catalog # Trino catalog name
schema: analytics # default schema (avoid mixed case)
# --- Auth (see Authentication section) ---
method: ldap # none | ldap | kerberos | jwt | certificate | oauth | oauth_console
user: john.doe
password: "{{ env_var('DBT_TRINO_PASSWORD') }}"
# --- Performance ---
threads: 8 # parallel model builds (default: 1)
retries: 5 # retry on connection error (default: 3)
# --- Session ---
timezone: Europe/Moscow # session timezone
session_properties:
query_max_run_time: 4h
join_reordering_strategy: AUTOMATIC
join_distribution_type: AUTOMATIC
task_writer_count: "4"
# --- Roles ---
roles:
iceberg_catalog: analyst # catalog: role
# --- Misc ---
http_headers:
X-Trino-Client-Info: dbt-trino
prepared_statements_enabled: true # for dbt seed (default: true)
Authentication methods
None (dev / local Trino without auth)
yaml
method: none
user: admin
LDAP (most common enterprise setup)
yaml
method: ldap
user: john.doe
password: "{{ env_var('DBT_TRINO_PASSWORD') }}"
# Optional: run queries as another user
impersonation_user: service_account
JWT
yaml
method: jwt
jwt_token: "{{ env_var('DBT_TRINO_JWT_TOKEN') }}"
Kerberos
yaml
method: kerberos
user: trino-service
keytab: /etc/security/trino.keytab
krb5_config: /etc/krb5.conf
principal: trino@REALM.EXAMPLE.COM
service_name: trino # default
hostname_override: REALM.EXAMPLE.COM # optional
mutual_authentication: false
Certificate (mTLS)
yaml
method: certificate
client_certificate: /path/to/client.crt
client_private_key: /path/to/client.key
cert: /path/to/ca.crt # optional CA bundle
OAuth (browser-based, Starburst Galaxy)
yaml
method: oauth
host: myaccount-mycluster.trino.galaxy.starburst.io
port: 443
database: dbt_target
schema: analytics
Starburst Galaxy user format
yaml
user: john.doe@mycompany.com/analyst_role # email/role

dbt Project Structure

Recommended layout for a Trino-backed dbt project:

my_project/
├── dbt_project.yml
├── profiles.yml # or ~/.dbt/profiles.yml
├── packages.yml
├── models/
│ ├── staging/ # Bronze → raw source cleaning, 1:1 with source tables
│ │ ├── _sources.yml # source() definitions
│ │ ├── _staging.yml # model docs + tests
│ │ └── stg_orders.sql
│ ├── intermediate/ # Silver → joins, enrichments, not exposed to BI
│ │ └── int_orders_enriched.sql
│ └── marts/ # Gold → business-facing, exposed to BI
│ ├── core/
│ │ └── fct_orders.sql
│ └── finance/
│ └── agg_revenue_daily.sql
├── seeds/ # small reference data (CSV)
├── snapshots/ # SCD Type 2 tables
├── tests/ # custom singular tests
├── macros/ # custom Jinja macros
└── analyses/ # ad-hoc SQL, not materialised
dbt_project.yml skeleton
yaml
name: my_project
version: 1.0.0
config-version: 2
profile: my_trino_project
model-paths: ["models"]
seed-paths: ["seeds"]
snapshot-paths: ["snapshots"]
macro-paths: ["macros"]
target-path: "target"
clean-targets: ["target", "dbt_packages"]
models:
my_project:
staging:
+materialized: view
+schema: staging
intermediate:
+materialized: view
+schema: intermediate
marts:
+materialized: table
+on_table_exists: drop # safe for Iceberg + Glue
+properties:
format: "'PARQUET'"

Materializations

View

Default. Rebuilt on every dbt run via CREATE OR REPLACE VIEW.

sql
-- models/staging/stg_events.sql
{{ config(materialized='view') }}
select
event_id,
cast(event_ts as timestamp(6) with time zone) as event_ts,
lower(event_type) as event_type,
user_id
from {{ source('raw', 'events') }}
where event_id is not null

view_security — controls whether the view runs with the definer's or invoker's permissions:

sql
{{ config(materialized='view', view_security='invoker') }}
Table

Rebuilt as a full table on every run. Use for mart-layer models queried by BI.

sql
{{ config(
materialized = 'table',
on_table_exists = 'drop', -- drop | rename | replace | skip
properties = {
"format": "'PARQUET'",
"partitioning": "ARRAY['day(event_ts)']",
"sorted_by": "ARRAY['user_id']",
}
) }}
select ...

on_table_exists options:

ValueBehaviourWhen to use
renameCreate temp → rename old to backup → rename temp to target (default)Standard Hive/Iceberg
dropDrop then recreateAWS Glue, Delta, Iceberg when rename fails
replaceCREATE OR REPLACE TABLEConnectors that support it
skipCREATE TABLE IF NOT EXISTSIdempotent create, never overwrites
Incremental

On first run: full CREATE TABLE AS SELECT. On subsequent runs: only new/changed rows are processed.

sql
-- models/marts/fct_events.sql
{{ config(
materialized = 'incremental',
unique_key = 'event_id',
incremental_strategy= 'merge',
on_schema_change = 'sync_all_columns',
properties = {
"format": "'PARQUET'",
"partitioning": "ARRAY['day(event_ts)']",
}
) }}
select
event_id,
user_id,
event_type,
event_ts
from {{ ref('stg_events') }}
{% if is_incremental() %}
where event_ts > (select max(event_ts) from {{ this }})
{% endif %}
Incremental strategies
Strategyunique_keyTrino connector supportDescription
appendnot requiredAllINSERT new rows only. No dedup.
mergerequiredIceberg, Delta (v2)MERGE INTO: UPDATE matched rows, INSERT new ones
delete+insertrequiredIceberg, HiveDELETE matching rows, then INSERT all — safe for partitioned tables

append — simplest, no dedup:

sql
{{ config(materialized='incremental') }}
select * from {{ ref('stg_events') }}
{% if is_incremental() %}
where event_ts > (select max(event_ts) from {{ this }})
{% endif %}

merge — upsert (requires Iceberg format_version=2):

sql
{{ config(
materialized='incremental',
unique_key=['user_id', 'date_day'],
incremental_strategy='merge',
) }}
select
user_id,
date_trunc('day', event_ts) as date_day,
count(*) as event_count,
max(event_ts) as last_seen_ts
from {{ ref('stg_events') }}
{% if is_incremental() %}
where event_ts >= (select max(last_seen_ts) from {{ this }}) - interval '1' day
{% endif %}
group by 1, 2

delete+insert — deletes rows matching unique_key then inserts; works reliably on partitioned Iceberg tables:

sql
{{ config(
materialized='incremental',
unique_key='order_id',
incremental_strategy='delete+insert',
properties={"partitioning": "ARRAY['day(created_at)']"},
) }}
select * from {{ ref('stg_orders') }}
{% if is_incremental() %}
where created_at >= (select max(created_at) from {{ this }}) - interval '1' day
{% endif %}
Incremental on Hive with partition overwrite

Enable in Trino catalog config:

<catalog>.insert-existing-partitions-behavior=OVERWRITE

Or via session property in profile:

yaml
session_properties:
hive.insert_existing_partitions_behavior: OVERWRITE

Model:

sql
{{ config(
materialized='incremental',
properties={
"format": "'PARQUET'",
"partitioned_by": "ARRAY['dt']",
}
) }}
select *, cast(event_ts as date) as dt
from {{ ref('stg_events') }}
{% if is_incremental() %}
where event_ts >= current_date - interval '3' day
{% endif %}
incremental_predicates — limit target table scan

For very large target tables, restrict how much of the target Trino scans during MERGE:

sql
{{ config(
materialized='incremental',
unique_key='event_id',
incremental_strategy='merge',
incremental_predicates=[
"DBT_INTERNAL_DEST.event_ts >= current_date - interval '7' day"
],
) }}

DBT_INTERNAL_DEST = alias for the target table; DBT_INTERNAL_SOURCE = alias for the new data CTE.

on_schema_change

Controls behaviour when source query columns differ from target table columns:

ValueBehaviour
ignoreDefault. New columns silently dropped; removing columns causes run failure
failError if schema diverges — forces explicit --full-refresh
append_new_columnsAdds new columns to target; keeps old columns
sync_all_columnsAdds new + removes dropped columns; handles type changes
sql
{{ config(
materialized='incremental',
on_schema_change='sync_all_columns',
) }}
Ephemeral

Not materialised in the warehouse — inlined as a CTE in dependent models. Use for lightweight reusable transformations.

sql
-- models/staging/stg_events_cleaned.sql
{{ config(materialized='ephemeral') }}
select * from {{ source('raw', 'events') }}
where event_id is not null
and event_type != 'test'

Downstream model sees it as:

sql
with __dbt__cte__stg_events_cleaned as (
select * from raw.events where ...
)
select * from __dbt__cte__stg_events_cleaned ...

Limits: cannot ref() from operations/macros; don't overuse — long CTE chains are hard to debug.

Materialized View

Backed by a Trino materialized view. dbt refreshes it on each dbt run.

sql
{{ config(
materialized='materialized_view',
properties={
'format': "'PARQUET'"
},
) }}
select
date_trunc('day', event_ts) as dt,
event_type,
count(*) as event_count
from {{ ref('stg_events') }}
group by 1, 2

Use when the connector manages refresh automatically and you want database-native incremental logic.


Table Properties

Set Iceberg/Hive/Delta table properties via the properties dict. Values are Trino SQL expressions (strings must be double-quoted to produce a SQL string literal):

sql
{{ config(
materialized='table',
properties={
-- File format
"format": "'PARQUET'", -- PARQUET | ORC | AVRO
-- Iceberg partitioning
"partitioning": "ARRAY['day(event_ts)', 'bucket(32, user_id)']",
-- Iceberg sorted_by (within data files)
"sorted_by": "ARRAY['user_id', 'event_type']",

This is the start of the file. Read the full SKILL.md on GitHub.

Security

  • Security scanPassed, 95 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

7-day trend score
0

Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/ivanshamaev/de-agent-skills/dbt-trino/badge)](https://verified-skill.com/skills/ivanshamaev/de-agent-skills/dbt-trino)

Something wrong with this skill or its page? Tell us.