trino-cli

Execute SQL queries against Treasure Data using the Trino CLI.

21|24|Updated Oct 21, 2025
One-click install
npx skills add https://github.com/treasure-data/td-skills --skill trino-cli
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: trino-cli
Source: https://github.com/treasure-data/td-skills/tree/main/sql-skills/trino-cli
Command: npx skills add https://github.com/treasure-data/td-skills --skill trino-cli

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill provides expert assistance for using the Trino CLI to query Treasure Data interactively from the command line, enabling quick ad-hoc data analysis, exploration, and scripting without a web console. It streamlines terminal-based data workflows, saving time for data professionals.

Core Features & Use Cases

  • Interactive Querying: Guides on connecting to TD, exploring databases/tables, and executing SQL queries directly from the terminal with immediate feedback.
  • Batch Execution: Explains how to run queries from files or stdin, ideal for automation, scheduled reports, and integrating TD queries into shell scripts.
  • Output Formatting: Demonstrates various output formats (CSV, JSON, Markdown) for integrating results with other tools or documentation, enhancing flexibility.
  • Use Case: A data engineer needs to quickly check the schema of a new table, run a few ad-hoc queries to understand data distribution, and then export a small dataset to a CSV file for a colleague. This skill helps them use the Trino CLI for all these tasks efficiently from their terminal.

Quick Start

Install Trino CLI (if not already)

curl -o trino https://repo1.maven.org/maven2/io/trino/trino-cli/477/trino-cli-477-executable.jar chmod +x trino sudo mv trino /usr/local/bin/

Connect and query

export TD_API_KEY="your_api_key_here" trino
--server https://api-presto.treasuredata.com
--catalog td
--user $TD_API_KEY
--schema sample_datasets
--execute "SELECT COUNT(*) FROM nasdaq"

Frequently Asked Questions about trino-cli

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I query Treasure Data from the command line?

Use the Trino CLI to query Treasure Data directly from your terminal. Install the executable, set your TD_API_KEY environment variable, and connect with `trino --server https://api-presto.treasuredata.com --catalog td --user $TD_API_KEY --schema [schema-name]` to run SQL queries interactively or in batch mode.

Can I run SQL queries from a file or script with Trino CLI?

Yes. Trino CLI supports batch execution via `--execute` for inline queries or `--file` to run queries from a file, making it ideal for automation, scheduled reports, and integrating Treasure Data queries into shell scripts without manual intervention.

What output formats does Trino CLI support for exporting query results?

Trino CLI supports multiple output formats including CSV, JSON, and Markdown, allowing you to export query results in the format that best suits integration with other tools, documentation systems, or downstream analysis workflows.

What are the prerequisites for using Trino CLI with Treasure Data?

You need Java 11 or higher, a Treasure Data API key (TD_API_KEY), and either a configuration file or environment variables specifying the server, catalog, user, and schema. Regional endpoints are supported for different data locations.

Is Trino CLI suitable for ad-hoc data exploration and schema inspection?

Yes. Trino CLI enables quick terminal-based data exploration, allowing you to inspect table schemas, run exploratory queries, and verify data distribution without leaving the command line or accessing a web console.

What happens if a query times out or fails in Trino CLI?

Trino CLI supports configurable timeout settings and error handling options to manage long-running queries and connection issues. You can adjust these parameters via CLI options to suit your workflow and network conditions.