Files
genai-toolbox/docs/en/resources/tools/trino/trino-sql.md
Abhinav Misra 7dd123b3d7 feat(trino): Add Trino source and tools (#948)
Add support for Trino distributed SQL query engine with complete
implementation including sources, tools, documentation, and tests.

## Summary

- Add Trino source implementation with multiple authentication methods
- Create trino-execute-sql tool for arbitrary SQL execution
- Create trino-sql tool for parameterized queries
- Add comprehensive documentation ~~and prebuilt configurations~~
- Include unit tests for all components

## Features

### Authentication Support
- Basic authentication (username/password)
- JWT token authentication
- Kerberos authentication
- SSL/TLS connections

### Tools
- **trino-execute-sql**: Execute arbitrary SQL queries
- **trino-sql**: Execute parameterized SQL with prepared statements
- Prebuilt tools for common operations (list catalogs, schemas, tables,
etc.)

### Cross-Catalog Queries
- Support for federated queries across multiple data sources
- Query Hive, PostgreSQL, MySQL, and other connectors in single queries
- Leverage Trino's distributed query engine capabilities

## Test Plan
- [x] Unit tests pass for source DSN generation
- [x] Unit tests pass for tool parameter validation
- [x] Project builds successfully with new dependencies
- [x] Documentation includes comprehensive examples

Ref #880

---------

Co-authored-by: Yuan Teoh <yuanteoh@google.com>
Co-authored-by: Yuan Teoh <45984206+Yuan325@users.noreply.github.com>
2025-08-22 00:03:04 +00:00

4.9 KiB

title, type, weight, description, aliases
title type weight description aliases
trino-sql docs 1 A "trino-sql" tool executes a pre-defined SQL statement against a Trino database.
/resources/tools/trino-sql

About

A trino-sql tool executes a pre-defined SQL statement against a Trino database. It's compatible with any of the following sources:

The specified SQL statement is executed as a prepared statement, and specified parameters will be inserted according to their position: e.g. $1 will be the first parameter specified, $2 will be the second parameter, and so on. If template parameters are included, they will be resolved before execution of the prepared statement.

Example

Note: This tool uses parameterized queries to prevent SQL injections. Query parameters can be used as substitutes for arbitrary expressions. Parameters cannot be used as substitutes for identifiers, column names, table names, or other parts of the query.

tools:
 search_orders_by_region:
    kind: trino-sql
    source: my-trino-instance
    statement: |
      SELECT * FROM hive.sales.orders
      WHERE region = $1
      AND order_date >= DATE($2)
      LIMIT 10
    description: |
      Use this tool to get information for orders in a specific region.
      Takes a region code and date and returns info on the orders.
      Do NOT use this tool with an order id. Do NOT guess a region code or date.
      A region code is a code for a geographic region consisting of two-character
      region designator and followed by optional subregion.
      For example, if given US-WEST, the region is "US-WEST".
      Another example for this is EU-CENTRAL, the region is "EU-CENTRAL".
      If the tool returns more than one option choose the date closest to today.
      Example:
      {{
          "region": "US-WEST",
          "order_date": "2024-01-01",
      }}
      Example:
      {{
          "region": "EU-CENTRAL",
          "order_date": "2024-01-15",
      }}
    parameters:
      - name: region
        type: string
        description: Region unique identifier
      - name: order_date
        type: string
        description: Order date in YYYY-MM-DD format

Example with Template Parameters

Note: This tool allows direct modifications to the SQL statement, including identifiers, column names, and table names. This makes it more vulnerable to SQL injections. Using basic parameters only (see above) is recommended for performance and safety reasons. For more details, please check templateParameters.

tools:
 list_table:
    kind: trino-sql
    source: my-trino-instance
    statement: |
      SELECT * FROM {{.tableName}}
    description: |
      Use this tool to list all information from a specific table.
      Example:
      {{
          "tableName": "hive.sales.orders",
      }}
    templateParameters:
      - name: tableName
        type: string
        description: Table to select from

Reference

field type required description
kind string true Must be "trino-sql".
source string true Name of the source the SQL should execute on.
description string true Description of the tool that is passed to the LLM.
statement string true SQL statement to execute on.
parameters parameters false List of parameters that will be inserted into the SQL statement.
templateParameters templateParameters false List of templateParameters that will be inserted into the SQL statement before executing prepared statement.