Agent skill
dbt
dbt with TD Trino. Covers profiles.yml setup (method:none, user:TD_API_KEY), required override macros (no CREATE VIEW), TD_INTERVAL in models, and TD Workflow deployment.
Install this agent skill to your Project
npx add-skill https://github.com/treasure-data/td-skills/tree/main/workflow-skills/dbt
SKILL.md
dbt with Treasure Data Trino
Installation
uv venv && source .venv/bin/activate
uv pip install dbt-core dbt-trino==1.9.3
profiles.yml
td:
target: dev
outputs:
dev:
type: trino
method: none # Not 'ldap'
user: "{{ env_var('TD_API_KEY') }}"
password: dummy # Not used
host: api-presto.treasuredata.com
port: 443
database: td # Always 'td'
schema: your_dev_database # Your TD database name
threads: 4
http_scheme: https
session_properties:
query_max_run_time: 1h
Key TD settings:
method: nonefor API key authdatabase: td(always)schema: your_td_database(what you see in TD Console)
Required Override Macros
TD doesn't support CREATE VIEW. Create macros/override_dbt_trino.sql:
{% macro trino__create_view_as(relation, sql) -%}
create or replace table {{ relation }} as (
{{ sql }}
);
{%- endmacro %}
{% macro trino__list_relations_without_caching(schema_relation) %}
{% call statement('list_relations_without_caching', fetch_result=True) %}
select
table_catalog as "database",
table_schema as "schema",
table_name as "name",
table_type as "type"
from {{ schema_relation }}.information_schema.tables
where table_schema = '{{ schema_relation.schema }}'
{% endcall %}
{{ return(load_result('list_relations_without_caching').table) }}
{% endmacro %}
dbt_project.yml
name: 'my_td_project'
version: '1.0.0'
config-version: 2
profile: 'td'
flags:
require_certificate_validation: true
vars:
target_range: '-3M/now'
models:
my_td_project:
+materialized: table
+on_schema_change: "append_new_columns"
Model Patterns
Basic model:
{{
config(materialized='table')
}}
SELECT
TD_TIME_STRING(time, 'd!', 'JST') as date,
COUNT(*) as event_count
FROM {{ source('raw', 'events') }}
WHERE TD_INTERVAL(time, '{{ var("target_range", "-7d") }}', 'JST')
GROUP BY 1
Incremental model:
{{
config(
materialized='incremental',
unique_key='event_id'
)
}}
SELECT *
FROM {{ source('raw', 'events') }}
WHERE TD_INTERVAL(time, '{{ var("target_range", "-1d") }}', 'JST')
{% if is_incremental() %}
AND time > (SELECT MAX(time) FROM {{ this }})
{% endif %}
Commands
dbt debug # Test connection
dbt run # Run all
dbt run --select daily_events # Run specific
dbt run --vars '{"target_range": "-1d"}' # Override variable
dbt run --full-refresh # Rebuild incremental
dbt test # Run tests
TD Workflow Deployment
# dbt_workflow.dig
timezone: Asia/Tokyo
schedule:
daily>: 03:00:00
_export:
docker:
image: "treasuredata/customscript-python:3.12.11-td1"
_env:
TD_API_KEY: ${secret:td.apikey}
+setup:
py>: tasks.InstallPackages
+dbt_run:
py>: dbt_wrapper.run_dbt
command_args: ['run', '--target', 'prod']
tasks.py:
def InstallPackages():
import subprocess, sys
subprocess.check_call([sys.executable, '-m', 'pip', 'install', 'dbt-core==1.10.9', 'dbt-trino==1.9.3'])
Common Errors
| Error | Fix |
|---|---|
| connector does not support creating views | Add override macro above |
| Table ownership information not available | Add override macro for list_relations |
| Var 'target_range' is undefined | Add default: {{ var('target_range', '-1d') }} |
Resources
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
email-campaign
This skill should be used when the user asks to "create an email", "build an email campaign", "design an email template", "generate an email for a segment", "preview an email", or "push an email to Engage". Generates enterprise-grade HTML email templates with live preview in Treasure Studio and natural language editing, then pushes the final version to Treasure Engage.
action-report
YAML format reference for action reports rendered via preview_action_report. MUST be read before writing any action report YAML — defines the report structure (title, summary, actions array) and action item fields (as_is, to_be, reason, priority, category, impact) with incremental build workflow. Required by seo-analysis and any skill that produces prioritized recommendations.
grid-dashboard
YAML format reference for grid dashboards rendered via preview_grid_dashboard. MUST be read before writing any dashboard YAML — defines the page structure, 6 cell types (kpi, gauge, scores, table, chart, markdown), grid layout rules, cell merging syntax, and incremental build workflow. Required by seo-analysis and any skill that produces visual data dashboards.
seo-analysis
Runs SEO and AEO (Answer Engine Optimization) analysis on websites or specific pages. Use when the user mentions SEO, AEO, search rankings, search optimization, or wants to analyze how their pages perform in search engines and AI answers. Produces a data dashboard and action report with before/after recommendations.
aps-doc-core
Core documentation generation patterns and framework for Treasure Data pipeline layers. Provides shared templates, quality validation, testing framework, and Confluence integration used by all layer-specific documentation skills.
aps-doc-id-unification
Expert documentation generation for ID unification layers. Documents identity resolution algorithms, merge strategies, match rules, entity graphs, and multi-workflow orchestration. Use when documenting ID unification processes.
Didn't find tool you were looking for?