Connect to Trino via CLI

Trino Client component

The Trino service includes a Trino Client component, which provides a command-line interface (CLI) for submitting SQL statements to the Trino Coordinator. By default, when a Trino Client component is installed, it is automatically configured to work with the Trino Coordinator available in your ADH cluster.

Usage

To connect to Trino via CLI, on the ADH host with the Trino Client component installed, run the command:

$ trino

This opens the Trino Client prompt:

trino>

To view the list of supported commands, execute the help command. Example:

help
Supported commands:
QUIT
EXIT
CLEAR
EXPLAIN [ ( option [, ...] ) ] <query>
    options: FORMAT { TEXT | GRAPHVIZ | JSON }
            TYPE { LOGICAL | DISTRIBUTED | VALIDATE | IO }
DESCRIBE <table>
SHOW COLUMNS FROM <table>
SHOW FUNCTIONS
SHOW CATALOGS [LIKE <pattern>]
SHOW SCHEMAS [FROM <catalog>] [LIKE <pattern>]
SHOW TABLES [FROM <schema>] [LIKE <pattern>]
USE [<catalog>.]<schema>

To clear the terminal screen, use the clear command. To exit the Trino CLI and go back to the OS CLI, use the exit or quit commands.

Statements execution

When the Trino Client prompt is active, you can run SQL statements. The CLI will return the results of statements processing and their statistics. Example:

select * from "hive-adh"."default"."solar_objects";

The output:

  name   |    mass    | diameter
---------+------------+----------
 Sun     | 1989100000 |  1392000
 Mercury |        330 |     4879
 Venus   |       4867 |    12104
 Earth   |       5972 |    12742
 Mars    |        642 |     6780
 Jupiter |    1898187 |   139822
 Saturn  |     568317 |   116464
 Uranus  |      86813 |    50724
 Neptune |     102413 |    49244
(9 rows)

Query 20250115_092203_00003_7thb6, FINISHED, 1 node
Splits: 1 total, 1 done (100,00%)
1,51 [9 rows, 172B] [5 rows/s, 114B/s]

In this example, hive-adh is the name of the catalog, default is the schema name, and solar_objects is the table name.

TIP
By using Trino Client settings in ADCM, you can specify the default Trino catalog and schema.

Configuration

By default, the Trino Client component is configured to work with the Trino Coordinator available in the ADH cluster and requires no manual setup. If you need to tune the Trino Client behavior, use the Trino Client settings in ADCM.

TLS/HTTPS

The Trino Client component supports secure connection to Trino Coordinator using TLS. To configure a secure connection, use the SSL Configuration section of the Trino Client component settings in ADCM.

Remote connection

You can also connect to your Trino service from a remote host outside the ADH cluster. For this, you can use the trino-cli tool. It is implemented by a self-executing JAR file, which can be launched in any OS provided there is a Java runtime environment (JRE) installed.

To use the Trino CLI tool, you need to download the JAR executable. The link to the most recent file is available at the Trino documentation website. If you use Linux OS, rename the file to trino and make it executable using the chmod +x command. If you use Windows OS, run the Windows CLI as administrator before you launch the JAR file in it.

To launch the Trino CLI tool, open a terminal in your OS and use the following command syntax, using the network address of the Trino Coordinator component.

  • Windows

  • Linux

java -jar trino-cli-468-executable.jar http://coordinator.trino.example:18188
$ ./trino http://coordinator.trino.example:18188

You can also use various options when starting the Trino CLI. A list of those options is provided on the Command line interface page of the Trino documentation.

Found a mistake? Seleсt text and press Ctrl+Enter to report it