Trino Query

Trino Query

Certified

Execute a SQL query using Trino query engine

Runs a SQL statement using Trino distributed SQL query engine. Supports querying data lakes, databases, and various data sources. Connection details can be set as typed properties, and the id the coordinator assigned to the query is returned as queryId output, with its Trino query stats metrics. With fetchType NONE, the result set is not drained just to collect stats, so emitted stats may be incomplete. WARNING: Do NOT include a semicolon at the end of your SQL query, it will result in an error. Supports parameterized queries and all fetch modes. Default fetchSize is 10,000 rows.

yaml
type: io.kestra.plugin.jdbc.trino.Query

Generate a CSV file report from a SQL query using Trino

yaml
id: trino_query
namespace: company.team

tasks:
  - id: analyze_orders
    type: io.kestra.plugin.jdbc.trino.Query
    url: jdbc:trino://localhost:8080/tpch
    sql: |
      select orderpriority as priority, sum(totalprice) as total
      from tpch.tiny.orders
      group by orderpriority
      order by orderpriority
    fetchType: STORE

  - id: csv_report
    type: io.kestra.plugin.serdes.csv.IonToCsv
    from: "{{ outputs.analyze_orders.uri }}"

Connect with typed properties and route the queries of the task in a Trino resource group

yaml
id: trino_query_typed_properties
namespace: company.team

tasks:
  - id: session_catalog
    type: io.kestra.plugin.jdbc.trino.Query
    url: jdbc:trino://trino.example.com:8443
    ssl: true
    username: "{{ secret('TRINO_USERNAME') }}"
    password: "{{ secret('TRINO_PASSWORD') }}"
    catalog: tpch
    schema: tiny
    clientTags:
      - reported_by_kestra
    sessionProperties:
      query_max_execution_time: 1h
    sql: SELECT * FROM orders LIMIT 10
    fetchType: FETCH
Installation

Our standard Docker images already include this plugin. If you use a -slim image or another setup, install it with the following command:

kestractl plugins get io.kestra.plugin:plugin-jdbc-trino --compatible-for $KESTRA_VERSION

For kestractl, use your Kestra version with --compatible-for, or specify an exact plugin version.

For Kestra CLI, replace LATEST with a specific version or version range to pin the plugin version.

Properties

SQL statement(s) to execute

Runs one or more SQL statements rendered with flow variables. Query tasks accept a single statement; Queries tasks can execute multiple statements separated by semicolons

The JDBC URL to connect to the database

The Trino access token used for JWT-based authentication

Sent as the accessToken connection property of the Trino JDBC driver, typically through {{ secret('TRINO_ACCESS_TOKEN') }} for an engine behind an OAuth2/OIDC authentication provider. Browser-based OAuth2 (externalAuthentication) is not supported as it cannot complete on a headless worker.

SQL to execute after main query in same transaction

Optional SQL executed in the same transaction after the main statement. Useful for marking rows as processed to avoid duplicates; only a single statement is allowed. Commit covers both sql and afterSQL

Assets this task consumes as inputs or produces as outputs, for lineage tracking and the asset graph (Enterprise Edition). A flow declaring this property on a task is rejected in the open-source edition.

Definitions
assetFailureBehaviorstring
Possible Values
IGNOREFAILWARN

Asset failure behavior

Behavior applied to the task state when a declared asset fails to render, emit, or be persisted (e.g. a lock conflict): FAIL escalates it to FAILED, WARN (default) warns it if it would otherwise succeed, IGNORE leaves the state untouched.

enableAutobooleanstring

Whether to auto-register assets referenced dynamically at runtime that are not statically declared in inputs or outputs.

inputsarray

The assets consumed as inputs.

id*string
Min length1
typestring
outputs

The assets produced as outputs.

id*string
Min length1
Max length150
type*object
descriptionstring
displayNamestring
metadataobject
Default{}
namespacestring
Min length1
Max length150
id*string
Min length1
Max length150
type*object
descriptionstring
displayNamestring
metadataobject
Default{}
namespacestring
Min length1
Max length150
id*string
Min length1
Max length150
type*object
descriptionstring
displayNamestring
metadataobject
Default{}
namespacestring
Min length1
Max length150
id*string
Min length1
Max length150
type*object
descriptionstring
displayNamestring
metadataobject
Default{}
namespacestring
Min length1
Max length150
id*string
Min length1
Max length150
type*object
descriptionstring
displayNamestring
metadataobject
Default{}
namespacestring
Min length1
Max length150
id*string
Min length1
Max length150
type*string
Min length1

Custom asset type

descriptionstring
displayNamestring
metadataobject
Default{}
namespacestring
Min length1
Max length150

The default catalog the connection runs against

Alternative to including the catalog in the JDBC URL path (jdbc: trino://host: port/<catalog>).

SubTypestring

The tags attached to the queries run by this task

Lets Trino administrators route Kestra queries in resource groups managed by resourceGroupManager. Passed to the driver as the clientTags connection property (comma-separated tag names).

Defaultfalse

Compute per-column statistics of the fetched rows

When true, writes an ION file with one entry per column (column, jdbcType, nulls, distinct (approximate), min, max, mean, median, minLen, maxLen) and exposes its URI in the columnStats output. Statistics are computed while the rows are read, without running a second query. Only applies to fetchType FETCH and STORE; LOB, binary and array columns are skipped. min and max are omitted for string columns longer than 256 characters, and median is computed on a bounded sample of the values

Default100000

Number of rows used to compute column statistics

Only used when columnStats is true. Statistics stop at this many rows while all rows are still fetched or stored. Must be at least 1. Default: 100,000

Extra authentication or connector-specific credentials sent as extraCredentials

Name: value pairs forwarded to the coordinator as authentication extra credentials (e.g. Kerberos delegation tokens, cloud object store keys for catalog authentication). The driver serializes them as name: value pairs joined with ;.

Default10000

Number of rows to fetch per database round trip

Controls JDBC fetch size for STORE mode. Default: 10,000 rows; use Integer.MIN_VALUE for MySQL streaming. Ignored for FETCH and FETCH_ONE

DefaultNONE
Possible Values
STOREFETCHFETCH_ONENONE

Result fetching mode

FETCH returns all rows, FETCH_ONE returns the first row only, STORE streams rows to internal storage (ION), NONE returns no data. Default: NONE

The Kerberos configuration (krb5.conf) file content

Written to the task working directory and passed to the driver as KerberosConfigPath.

The keytab file content holding the user Kerberos keys

Written to the task working directory and passed to the driver as KerberosKeytabPath, so the keytab does not have to be pre-mounted on the worker.

The Kerberos principal the connection authenticates as

Passed to the driver as KerberosPrincipal.

The remote service (cluster coordinator) name Kerberos tickets are requested for

Passed to the driver as KerberosRemoteServiceName.

SubTypestring

Output file names to capture after SQL execution

Creates named temporary files in the task working directory before the SQL runs, making their absolute paths available as {{ outputFiles.name }} Pebble variables in the SQL template. Only supported by embedded, in-process drivers (DuckDB, SQLite) where the database engine writes to the same filesystem as the Kestra worker. Remote database drivers (Postgres, MySQL, etc.) do not support this — they execute SQL on a separate server that cannot write to the Kestra worker filesystem.

Defaultfalse

Expose the executed SQL statement in the outputs

When true, the rendered SQL is exposed in the statement output, with the values of the secret() calls used in sql replaced by *** and truncated to 64 KiB. Disabled by default so that SQL text never leaks into outputs unless requested

Named parameter bindings for SQL query

Map of parameter names to values, bound to : name placeholders as prepared-statement parameters; supports nulls and typed values. Colons in literals, quoted identifiers, comments and :: casts are left as is; a : name missing from this map is bound to NULL with a warning.

The database user's password

The catalog roles to use, as a catalog name to role mapping

Role values are a named role (e.g. admin), all or none, and the pseudo-catalog system sets the role of every catalog without an explicit entry. Passed to the driver as the roles connection property (catalog: role values joined with ;).

The default schema the connection runs against

Only used when catalog is set, either here or in the JDBC URL path.

The Trino session properties to set at connection time

Catalog-scoped properties use the catalog.property Java-style name (e.g. hive.parquet_use_column_names). Passed to the driver as the sessionProperties connection property (name: value pairs joined with ;).

The client source name reported to the coordinator for every query of this task

Visible in system.runtime.queries and in the coordinator UI and usable in resourceGroupManager selectors: defaults to kestra so Kestra traffic can be identified and capacity-planned independently of other Trino clients.

Whether to use TLS/SSL when connecting to Trino

Sets the SSL connection property of the Trino JDBC driver. Required with a password (the driver refuses authentication with a password over plain HTTP) and when the coordinator certificate must be validated by sslTrustStore. This is the only property the driver accepts both from the URL and here; when set it overrides the URL value.

The client keystore content used for mutual TLS (client certificate) authentication

The keystore content (the bytes of a PKCS12 or JKS keystore base64-encoded, or a kestra:// internal storage file URI), written to the task working directory and passed to the driver as SSLKeyStorePath, so nothing has to be pre-mounted on the worker. When this is set, ssl: true is expected as well.

The password of the client keystore, when it is protected

The type of the client keystore, PKCS12 (default) or JKS

Passed to the driver as SSLKeyStoreType.

The truststore content used to validate the Trino coordinator certificate chain

The truststore content (the bytes of a PKCS12 or JKS truststore base64-encoded, or a kestra:// internal storage file URI), written to the task working directory and passed to the driver as SSLTrustStorePath.

The password of the truststore, when it is protected

The type of the truststore, PKCS12 (default) or JKS

Passed to the driver as SSLTrustStoreType.

Possible Values
FULLCANONE

The TLS/SSL certificate verification policy used by the Trino JDBC driver

FULL (driver default) validates the server certificate chain against the JVM truststore, CA validates it against the configured sslTrustStore only, and NONE skips validation (for example, a self-signed development coordinator).

The time zone id to use for date/time manipulation. Default value is the worker's default time zone id

The database user

Size of the stored result file in bytes

Only populated when fetchType is STORE

Formaturi

URI of the column statistics file in internal storage

Only populated when columnStats is true and fetchType is FETCH or STORE; file is stored in ION format

Statement execution duration in milliseconds

Includes reading the result rows

Engine query identifier

The id the engine coordinator assigned to the query, for example the Trino query id. Not set when the engine does not expose one.

First row of fetched data

Only populated when fetchType is FETCH_ONE

SubTypeobject

List of all fetched rows

Only populated when fetchType is FETCH

Number of rows affected by the statement

Reported by the JDBC driver for INSERT, UPDATE, DELETE and similar statements. Not set when the statement returns a result set or when the driver does not report a count

Number of rows fetched

Only populated when fetchType is FETCH or STORE

Executed SQL statement

Only populated when outputStatement is true. Values of secret() calls are replaced by *** and the text is truncated to 64 KiB

Tables read or written by the statement

Detected from the SQL text, so this is a best effort: CTEs, temporary tables and dialect specific syntax can lower the confidence or be missed. Limited to 50 entries, see tablesTruncated

Definitions
accessstring
Possible Values
READWRITECREATEDROP

How the statement uses the table

One of READ, WRITE, CREATE or DROP.

confidencestring
Possible Values
MEDIUMLOW

How reliable the detection is

MEDIUM when detected from the SQL text, LOW for temporary tables and ambiguous names.

databasestring

Database name

Null when the statement does not qualify the table with a database.

kindstring
Possible Values
TABLEFILEURL

Kind of source

Only set on DuckDB: TABLE, FILE or URL (files read through read_parquet, read_csv, ATTACH and quoted paths).

namestring

Table name

For DuckDB file reads, the file path or URL.

schemastring

Schema name

Null when the statement does not qualify the table with a schema.

Whether the tables list was cut at 50 entries

Formaturi

URI of stored results in internal storage

Only populated when fetchType is STORE; file is stored in internal storage using ION format

Number of SQL warnings raised by the statement

Count of the SQLWarning chain reported by the driver, for example Postgres notices

Unitbytes

The size of the stored result file.

The total CPU time spent by the Trino coordinator for the query.

The duration of the SQL execution, including reading the result rows.

Unitrows

The number of fetched rows.

Unitbytes

The peak memory bytes used by the Trino coordinator for the query.

Unitbytes

The number of bytes physically written by the Trino coordinator for the query.

Unitbytes

The number of bytes processed by the Trino coordinator for the query.

Unitrows

The number of rows processed by the Trino coordinator for the query.

The time the query spent queued on the Trino coordinator before running.

Unitrows

The number of rows affected, as reported by the JDBC driver.

The wall clock time spent by the Trino coordinator for the query.