smithery/treasure-data

trino

TD Trino SQL with TD-specific functions (td_interval, td_time_range, td_time_string, td_sessionize). Use for time-based filtering, partition pruning, and TD query patterns.

Installation

$ npx skills add smithery/treasure-data --skill trino

Similar popular skills

Related neighbors and high-traction skills in the same topics — useful to compare before installing.

Also in this package

Other skills from smithery/treasure-data · top by installs.

npx skills add smithery/treasure-data

Browse all from smithery/treasure-data

More details

Agent compatibility

Declared targets from SKILL.md / docs. Unmarked agents are not listed — the skill may still install via the CLI.

Claude Code Not declared
Cursor Not declared
Codex Not declared
GitHub Copilot Not declared
Windsurf Not declared
Gemini CLI Not declared
Cline Not declared
OpenCode Not declared

Package contents

Files included with this skill beyond the listing page.

  • skill md SKILL.md 2,557 B
  • docs SUMMARY.md 185 B

History

  1. First recorded snapshot · 0 installs

SKILL.md

TD Trino SQL

TD Time Functions

td_interval (Recommended for relative time)

where td_interval(time, '-1d', 'JST')      -- Yesterday (JST)
where td_interval(time, '-1d')             -- Yesterday (UTC)
where td_interval(time, '-1w', 'JST')      -- Previous week
where td_interval(time, '-1M', 'JST')      -- Previous month
where td_interval(time, '-1d/-1d', 'JST')  -- 2 days ago
where td_interval(time, '-1M/-2M', 'JST')  -- 3 months ago

Timezone is optional (defaults to UTC).

Note: Cannot use tdscheduledtime() as first arg. Include tdscheduledtime() elsewhere in query to establish reference date.

tdtimerange (Explicit dates)

where td_time_range(time, '2024-01-01', '2024-01-31')
where td_time_range(time, td_time_add(td_scheduled_time(), '-7d'), td_scheduled_time())

tdtimestring (Display formatting)

td_time_string(time, 'd!')         -- 2024-01-15 (UTC)
td_time_string(time, 'd!', 'JST')  -- 2024-01-15 (JST)
td_time_string(time, 's!', 'JST')  -- 2024-01-15 10:30:45
td_time_string(time, 'M!')         -- 2024-01
td_time_string(time, 'h!')         -- 2024-01-15 10

Format codes: y!=year, q!=quarter, M!=month, w!=week, d!=day, h!=hour, m!=minute, s!=second. Without the exclamation mark, includes timezone offset. Timezone is optional (defaults to UTC).

Use for display only, never for filtering:

  • Good: select tdtimestring(time, 'd!', 'JST') as date
  • Bad: where tdtimestring(time, 'd!', 'JST') = '2024-01-01'

tdtimeformat (Legacy)

td_time_format(time, 'yyyy-MM-dd HH:mm:ss', 'JST')

td_sessionize

select td_sessionize(time, 1800, user_id) as session_id  -- 30min timeout
from events

Table Format

select * from database_name.table_name
where td_interval(time, '-1d', 'JST')

Performance

Always include time filters for partition pruning:

-- Good: Partition pruning
where td_time_range(time, '2024-01-01', '2024-01-02')

-- Bad: Full table scan
where event_type = 'click'  -- Missing time filter!

Use approxdistinct() and approxpercentile() for large datasets.

Common Errors

Error Fix
Query exceeded memory limit Add time filters, use approx_ functions
Partition not found Verify time range syntax

Resources