# Command line interface The Trino CLI provides a terminal-based, interactive shell for running queries. The CLI is a [self-executing](http://skife.org/java/unix/2011/06/20/really_executable_jars.html) JAR file, which means it acts like a normal UNIX executable. The CLI uses the [](/client/client-protocol) over HTTP/HTTPS to communicate with the coordinator on the cluster. ## Requirements The Trino CLI has the following requirements: * Java version 11 or higher available on the path. Java 22 or higher is recommended for improved decompression performance. * Network access over HTTP/HTTPS to the coordinator of the Trino cluster. * Network access to the configured object storage, if the [](cli-spooling-protocol) is enabled. The CLI version should be identical to the version of the Trino cluster, or newer. Older versions typically work, but only a subset is regularly tested. Versions before 350 are not supported. (cli-installation)= ## Installation Download {download_gh}`cli`, rename it to `trino`, make it executable with `chmod +x`, and run it to show the version of the CLI: ```text ./trino --version ``` Run the CLI with `--help` or `-h` to see all available options. Windows users, and users unable to execute the preceding steps, can use the equivalent `java` command with the `-jar` option to run the CLI, and show the version: ```text java -jar trino-cli-*-executable.jar --version ``` The syntax can be used for the examples in the following sections. In addition, using the `java` command allows you to add configuration options for the Java runtime with the `-D` syntax. You can use this for debugging and troubleshooting, such as when {ref}`specifying additional Kerberos debug options `. ## Running the CLI The minimal command to start the CLI in interactive mode specifies the URL of the coordinator in the Trino cluster: ```text ./trino http://trino.example.com:8080 ``` If successful, you will get a prompt to execute commands. Use the `help` command to see a list of supported commands. Use the `clear` command to clear the terminal. To stop and exit the CLI, run `exit` or `quit`.: ```text trino> help Supported commands: QUIT EXIT CLEAR EXPLAIN [ ( option [, ...] ) ] options: FORMAT { TEXT | GRAPHVIZ | JSON } TYPE { LOGICAL | DISTRIBUTED | VALIDATE | IO } DESCRIBE SHOW COLUMNS FROM
SHOW FUNCTIONS SHOW CATALOGS [LIKE ] SHOW SCHEMAS [FROM ] [LIKE ] SHOW TABLES [FROM ] [LIKE ] USE [.] ``` You can now run SQL statements. After processing, the CLI will show results and statistics. ```text trino> SELECT count(*) FROM tpch.tiny.nation; _col0 ------- 25 (1 row) Query 20220324_213359_00007_w6hbk, FINISHED, 1 node Splits: 13 total, 13 done (100.00%) 2.92 [25 rows, 0B] [8 rows/s, 0B/s] ``` As part of starting the CLI, you can set the default catalog and schema. This allows you to query tables directly without specifying catalog and schema. ```text ./trino http://trino.example.com:8080/tpch/tiny trino:tiny> SHOW TABLES; Table ---------- customer lineitem nation orders part partsupp region supplier (8 rows) ``` You can also set the default catalog and schema with the {doc}`/sql/use` statement. ```text trino> USE tpch.tiny; USE trino:tiny> ``` Many other options are available to further configure the CLI in interactive mode: :::{list-table} :widths: 40, 60 :header-rows: 1 * - Option - Description * - `--catalog` - Sets the default catalog. Optionally also use `--schema` to set the default schema. You can change the default catalog and default schema with[](/sql/use). * - `--client-info` - Adds arbitrary text as extra information about the client. * - `--client-request-timeout` - Sets the duration for query processing, after which, the client request is terminated. Defaults to `2m`. * - `--client-tags` - Adds extra tags information about the client and the CLI user. Separate multiple tags with commas. The tags can be used as input for [](/admin/resource-groups). * - `--debug` - Enables display of debug information during CLI usage for [](cli-troubleshooting). Displays more information about query processing statistics. * - `--decimal-data-size` - Show data size and rate in base 10 (kB, MB, etc.) rather than the default base 2 (KiB, MiB, etc.). * - `--disable-auto-suggestion` - Disables autocomplete suggestions. * - `--disable-compression` - Disables compression of query results. * - `--editing-mode` - Sets key bindings in the CLI to be compatible with VI or EMACS editors. Defaults to `EMACS`. * - `--extra-credential` - Extra credentials (property can be used multiple times; format is key=value) * - `--extra-header` - HTTP header to add to the authenticated HTTP requests (property can be used multiple times; format is key=value). * - `--oauth2-client-id` - OAuth2 client ID for client credentials authentication. Requires `--oauth2-client-secret` to also be set. * - `--oauth2-client-secret` - Prompt for OAuth2 client secret for client credentials authentication. You can set the `TRINO_OAUTH2_CLIENT_SECRET` environment variable with the OAuth2 client secret value to avoid the prompt. For more information, see [](cli-oauth2-client-credentials-auth) * - `--oauth2-token-endpoint` - Optional `https://` URL of the OAuth2 token endpoint that the client credentials are exchanged at. When set, the secret is only ever sent to this endpoint, and a token endpoint advertised by the server is used only when it matches this value. When not set, the token endpoint advertised by the server is used, and it must be an `https://` URL. * - `--oauth2-scope` - Optional OAuth2 scope requested for client credentials authentication. When set, it overrides the scope advertised by the server in its authentication challenge. * - `--http-proxy` - Configures the URL of the HTTP proxy to connect to Trino. * - `--history-file` - Path to the [history file](cli-history). Defaults to `~/.trino_history`. * - `--network-logging` - Configures the level of detail provided for network logging of the CLI. Defaults to `NONE`, other options are `BASIC`, `HEADERS`, or `BODY`. * - `--output-format-interactive=` - Specify the [format](cli-output-format) to use for printing query results. Defaults to `ALIGNED`. * - `--pager=` - Path to the pager program used to display the query results. Set to an empty value to completely disable pagination. Defaults to `less` with a carefully selected set of options. * - `--no-progress` - Do not show query processing progress. * - `--path` - Set the default [SQL path](/sql/set-path) for the session. Useful for setting a catalog and schema location for [](udf-catalog). * - `--password` - Prompts for a password. Use if your Trino server requires password authentication. You can set the `TRINO_PASSWORD` environment variable with the password value to avoid the prompt. For more information, see [](cli-username-password-auth). * - `--schema` - Sets the default schema. Must be combined with `--catalog`. You can change the default catalog and default schema with [](/sql/use). * - `--server` - The HTTP/HTTPS address and port of the Trino coordinator. The port must be set to the port the Trino coordinator is listening for connections on. Port 80 for HTTP and Port 443 for HTTPS can be omitted. Trino server location defaults to `http://localhost:8080`. Can only be set if URL is not specified. * - `--session` - Sets one or more [session properties](session-properties-definition). Property can be used multiple times with the format `session_property_name=value`. * - `--socks-proxy` - Configures the URL of the SOCKS proxy to connect to Trino. * - `--source` - Specifies the name of the application or source connecting to Trino. Defaults to `trino-cli`. The value can be used as input for [](/admin/resource-groups). * - `--theme=` - Selects the color theme for styled output. Options are `AUTO`, `DARK`, `LIGHT`, `NONE`, `SOLARIZED_DARK`, `SOLARIZED_LIGHT`, `DRACULA`, `NORD`, or `GRUVBOX_DARK`. Defaults to `AUTO`, which uses `DARK` for an interactive terminal and disables color for a non-interactive terminal or when the `NO_COLOR` environment variable is set. An explicit value other than `AUTO` always applies, even when `NO_COLOR` is set. Use `NONE` to disable color. The named schemes use 24-bit color, which is approximated on terminals without truecolor support. * - `--timezone` - Sets the time zone for the session using the [time zone name]( ). Defaults to the timezone set on your workstation. * - `--user` - Sets the username for [](cli-username-password-auth). Defaults to your operating system username. You can override the default username, if your cluster uses a different username or authentication mechanism. ::: Most of the options can also be set as parameters in the URL. This means a JDBC URL can be used in the CLI after removing the `jdbc:` prefix. However, the same parameter may not be specified using both methods. See {doc}`the JDBC driver parameter reference ` to find out URL parameter names. For example: ```text ./trino 'https://trino.example.com?SSL=true&SSLVerification=FULL&clientInfo=extra' ``` (cli-tls)= ## TLS/HTTPS Trino is typically available with an HTTPS URL. This means that all network traffic between the CLI and Trino uses TLS. {doc}`TLS configuration ` is common, since it is a requirement for {ref}`any authentication `. Use the HTTPS URL to connect to the server: ```text ./trino https://trino.example.com ``` The recommended TLS implementation is to use a globally trusted certificate. In this case, no other options are necessary, since the JVM running the CLI recognizes these certificates. Use the options from the following table to further configure TLS and certificate usage: :::{list-table} :widths: 40, 60 :header-rows: 1 * - Option - Description * - `--insecure` - Skip certificate validation when connecting with TLS/HTTPS (should only be used for debugging). * - `--keystore-path` - The location of the Java Keystore file that contains the certificate of the server to connect with TLS. * - `--keystore-password` - The password for the keystore. This must match the password you specified when creating the keystore. * - `--keystore-type` - Determined by the keystore file format. The default keystore type is JKS. This advanced option is only necessary if you use a custom Java Cryptography Architecture (JCA) provider implementation. * - `--use-system-keystore` - Use a client certificate obtained from the system keystore of the operating system. Windows and macOS are supported. For other operating systems, the default Java keystore is used. The keystore type can be overridden using `--keystore-type`. * - `--truststore-password` - The password for the truststore. This must match the password you specified when creating the truststore. * - `--truststore-path` - The location of the Java truststore file that will be used to secure TLS. It cannot be used with an `http://` server URL. With an `http://` server URL, HTTPS spooled segment downloads are verified against the default Java truststore, so a private CA must be added to that truststore. * - `--truststore-type` - Determined by the truststore file format. The default keystore type is JKS. This advanced option is only necessary if you use a custom Java Cryptography Architecture (JCA) provider implementation. * - `--use-system-truststore` - Verify the server certificate using the system truststore of the operating system. Windows and macOS are supported. For other operating systems, the default Java truststore is used. The truststore type can be overridden using `--truststore-type`. ::: (cli-authentication)= ## Authentication The Trino CLI supports many {doc}`/security/authentication-types` detailed in the following sections: (cli-username-password-auth)= ### Username and password authentication Username and password authentication is typically configured in a cluster using the `PASSWORD` {doc}`authentication type `, for example with {doc}`/security/ldap` or {doc}`/security/password-file`. The following code example connects to the server, establishes your username, and prompts the CLI for your password: ```text ./trino https://trino.example.com --user=exampleusername --password ``` Alternatively, set the password as the value of the `TRINO_PASSWORD` environment variable. Typically use single quotes to avoid problems with special characters such as `$`: ```text export TRINO_PASSWORD='LongSecurePassword123!@#' ``` If the `TRINO_PASSWORD` environment variable is set, you are not prompted to provide a password to connect with the CLI. (cli-external-sso-auth)= ### External authentication - SSO Use the `--external-authentication` option for browser-based SSO authentication, as detailed in {doc}`/security/oauth2`. With this configuration, the CLI displays a URL that you must open in a web browser for authentication. The detailed behavior is as follows: - Start the CLI with the `--external-authentication` option and execute a query. - The CLI starts and connects to Trino. - A message appears in the CLI directing you to open a browser with a specified URL when the first query is submitted. - Open the URL in a browser and follow through the authentication process. - The CLI automatically receives a token. - When successfully authenticated in the browser, the CLI proceeds to execute the query. - Further queries in the CLI session do not require additional logins while the authentication token remains valid. Token expiration depends on the external authentication type configuration. - Expired tokens force you to log in again. (cli-oauth2-client-credentials-auth)= ### OAuth2 client credentials authentication OAuth2 client credentials authentication is used for non-interactive (machine-to-machine) authentication using the OAuth2 client credentials flow, as detailed in {doc}`/security/oauth2`. Unlike browser-based SSO, the client authenticates directly with a client ID and secret without user involvement. The following example connects to the server and prompts the CLI for your client secret: ```text ./trino https://trino.example.com --oauth2-client-id=myclientid --oauth2-client-secret ``` The client secret is exchanged for a token at the OAuth2 token endpoint advertised by the server, which must be an `https://` URL. To pin the token endpoint to a trusted value instead, set `--oauth2-token-endpoint`; the CLI then sends the secret only to that endpoint and rejects a server-advertised endpoint that does not match it. Alternatively, set the client secret as the value of the `TRINO_OAUTH2_CLIENT_SECRET` environment variable. Typically use single quotes to avoid problems with special characters such as `$`: ```text export TRINO_OAUTH2_CLIENT_SECRET='MyClientSecret123!@#' ``` If the `TRINO_OAUTH2_CLIENT_SECRET` environment variable is set, you are not prompted to provide a client secret to connect with the CLI. (cli-certificate-auth)= ### Certificate authentication Use the following CLI arguments to connect to a cluster that uses {doc}`certificate authentication `. :::{list-table} CLI options for certificate authentication :widths: 35 65 :header-rows: 1 * - Option - Description * - `--keystore-path=` - Absolute or relative path to a [PEM](/security/inspect-pem) or [JKS](/security/inspect-jks) file, which must contain a certificate that is trusted by the Trino cluster you are connecting to. * - `--keystore-password=` - Only required if the keystore has a password. ::: The truststore related options are independent of client certificate authentication with the CLI; instead, they control the client's trust of the server's certificate. (cli-jwt-auth)= ### JWT authentication To access a Trino cluster configured to use {doc}`/security/jwt`, use the `--access-token=` option to pass a JWT to the server. (cli-kerberos-auth)= ### Kerberos authentication The Trino CLI can connect to a Trino cluster that has {doc}`/security/kerberos` enabled. Invoking the CLI with Kerberos support enabled requires a number of additional command line options. You also need the {ref}`Kerberos configuration files ` for your user on the machine running the CLI. The simplest way to invoke the CLI is with a wrapper script: ```text #!/bin/bash ./trino \ --server https://trino.example.com \ --krb5-config-path /etc/krb5.conf \ --krb5-principal someuser@EXAMPLE.COM \ --krb5-keytab-path /home/someuser/someuser.keytab \ --krb5-remote-service-name trino ``` When using Kerberos authentication, access to the Trino coordinator must be through {doc}`TLS and HTTPS `. The following table lists the available options for Kerberos authentication: :::{list-table} CLI options for Kerberos authentication :widths: 40, 60 :header-rows: 1 * - Option - Description * - `--krb5-config-path` - Path to Kerberos configuration files. * - `--krb5-credential-cache-path` - Kerberos credential cache path. * - `--krb5-disable-remote-service-hostname-canonicalization` - Disable service hostname canonicalization using the DNS reverse lookup. * - `--krb5-keytab-path` - The location of the keytab that can be used to authenticate the principal specified by `--krb5-principal`. * - `--krb5-principal` - The principal to use when authenticating to the coordinator. * - `--krb5-remote-service-name` - Trino coordinator Kerberos service name. * - `--krb5-service-principal-pattern` - Remote kerberos service principal pattern. Defaults to `${SERVICE}@${HOST}`. ::: (cli-kerberos-debug)= #### Additional Kerberos debugging information You can enable additional Kerberos debugging information for the Trino CLI process by passing `-Dsun.security.krb5.debug=true`, `-Dtrino.client.debugKerberos=true`, and `-Djava.security.debug=gssloginconfig,configfile,configparser,logincontext` as a JVM argument when {ref}`starting the CLI process `: ```text java \ -Dsun.security.krb5.debug=true \ -Djava.security.debug=gssloginconfig,configfile,configparser,logincontext \ -Dtrino.client.debugKerberos=true \ -jar trino-cli-*-executable.jar \ --server https://trino.example.com \ --krb5-config-path /etc/krb5.conf \ --krb5-principal someuser@EXAMPLE.COM \ --krb5-keytab-path /home/someuser/someuser.keytab \ --krb5-remote-service-name trino ``` For help with interpreting Kerberos debugging messages, see {ref}`additional resources `. ## Pagination By default, the results of queries are paginated using the `less` program which is configured with a carefully selected set of options. This behavior can be overridden by setting the `--pager` option or the `TRINO_PAGER` environment variable to the name of a different program such as `more` or [pspg](https://github.com/okbob/pspg), or it can be set to an empty value to completely disable pagination. (cli-history)= ## History The CLI keeps a history of your previously used commands. You can access your history by scrolling or searching. Use the up and down arrows to scroll and {kbd}`Control+S` and {kbd}`Control+R` to search. To execute a query again, press {kbd}`Enter`. By default, you can locate the Trino history file in `~/.trino_history`. Use the `--history-file` option or the `TRINO_HISTORY_FILE` environment variable to change the default. ### Auto suggestion The CLI generates autocomplete suggestions based on command history. Press {kbd}`→` to accept the suggestion and replace the current command line buffer. Press {kbd}`Ctrl+→` ({kbd}`Option+→` on Mac) to accept only the next keyword. Continue typing to reject the suggestion. (cli-configuration-file)= ## Configuration file The CLI can read default values for all options from a file. It uses the first file found from the ordered list of locations: - File path set as value of the `TRINO_CONFIG` environment variable. - `.trino_config` in the current users home directory. - `$XDG_CONFIG_HOME/trino/config`. For example, you could create separate configuration files with different authentication options, like `kerberos-cli.properties` and `ldap-cli.properties`. Assuming they're located in the current directory, you can set the `TRINO_CONFIG` environment variable for a single invocation of the CLI by adding it before the `trino` command: ```text TRINO_CONFIG=kerberos-cli.properties trino https://first-cluster.example.com:8443 TRINO_CONFIG=ldap-cli.properties trino https://second-cluster.example.com:8443 ``` In the preceding example, the default configuration files are not used. You can use all supported options without the `--` prefix in the configuration properties file. Options that normally don't take an argument are boolean, so set them to either `true` or `false`. For example: ```properties output-format-interactive=AUTO timezone=Europe/Warsaw user=trino-client network-logging=BASIC krb5-disable-remote-service-hostname-canonicalization=true ``` ## Batch mode Running the Trino CLI with the `--execute`, `--file`, or passing queries to the standard input uses the batch (non-interactive) mode. In this mode the CLI does not report progress, and exits after processing the supplied queries. Results are printed in `CSV` format by default. You can configure other formats and redirect the output to a file. The following options are available to further configure the CLI in batch mode: :::{list-table} :widths: 40, 60 :header-rows: 1 * - Option - Description * - `--agent`, `--no-agent` - Turn [agent mode](cli-agent-mode) on or off. By default it is turned on when an AI agent is detected. * - `--agent-max-bytes=` - Maximum size of the rows that agent mode prints in full. Defaults to `10000`. A value of `0` or less means unlimited. * - `--agent-max-cell-width=` - Maximum width of a value in agent mode. Defaults to `500`. A value of `0` or less means unlimited. * - `--agent-max-rows=` - Maximum number of rows that agent mode prints in full. Defaults to `1000`. A value of `0` or less means unlimited. * - `--execute=` - Execute specified statements and exit. * - `-f`, `--file=` - Execute statements from file and exit. * - `--ignore-errors` - Continue processing in batch mode when an error occurs. Default is to exit immediately. * - `--output-format=` - Specify the [format](cli-output-format) to use for printing query results. Defaults to `CSV`. * - `--progress` - Show query progress in batch mode. It does not affect the output, which, for example can be safely redirected to a file. ::: ### Examples Consider the following command run as shown, or with the `--output-format=CSV` option, which is the default for non-interactive usage: ```text trino --execute 'SELECT nationkey, name, regionkey FROM tpch.sf1.nation LIMIT 3' ``` The output is as follows: ```text "0","ALGERIA","0" "1","ARGENTINA","1" "2","BRAZIL","1" ``` The output with the `--output-format=JSON` option: ```json {"nationkey":0,"name":"ALGERIA","regionkey":0} {"nationkey":1,"name":"ARGENTINA","regionkey":1} {"nationkey":2,"name":"BRAZIL","regionkey":1} ``` The output with the `--output-format=ALIGNED` option, which is the default for interactive usage: ```text nationkey | name | regionkey ----------+-----------+---------- 0 | ALGERIA | 0 1 | ARGENTINA | 1 2 | BRAZIL | 1 ``` The output with the `--output-format=VERTICAL` option: ```text -[ RECORD 1 ]-------- nationkey | 0 name | ALGERIA regionkey | 0 -[ RECORD 2 ]-------- nationkey | 1 name | ARGENTINA regionkey | 1 -[ RECORD 3 ]-------- nationkey | 2 name | BRAZIL regionkey | 1 ``` The preceding command with `--output-format=NULL` produces no output. However, if you have an error in the query, such as incorrectly using `region` instead of `regionkey`, the command has an exit status of 1 and displays an error message (which is unaffected by the output format): ```text Query 20200707_170726_00030_2iup9 failed: line 1:25: Column 'region' cannot be resolved SELECT nationkey, name, region FROM tpch.sf1.nation LIMIT 3 ``` (cli-agent-mode)= ## Agent mode Agent mode prepares the CLI for programs, such as AI agents, that run queries in batch mode and read the output through a pipe. It limits the size of the output, so that a large result does not fill the context of the program, and reports errors in a format that is simple to parse. Agent mode does not change interactive use, and it does not change the exit status of the CLI. Agent mode is turned on in one of the following ways, listed in order of precedence: * The `--agent` option turns it on, and `--no-agent` turns it off. * The `TRINO_AGENT_MODE` environment variable turns it on with the value `1` and off with `0`. * The CLI turns it on when all of the following conditions are met: * One of the environment variables `AGENT`, `AI_AGENT`, `CLAUDECODE`, `CODEX_CI`, `CODEX_SANDBOX`, `CODEX_THREAD_ID`, `COPILOT_CLI`, `CURSOR_AGENT`, `GEMINI_CLI`, `GROK_AGENT`, `MUSE_SESSION_ID`, or `MUSE_THREAD_ID` is set. * The standard output of the CLI is not a terminal. It can be a pipe or a file, as agents often write the output of a command to a file. * No output format is set with `--output-format` on the command line. An `output-format` in the [configuration file](cli-configuration-file) does not stop detection, and agent mode then uses the `AGENT` format instead. To turn agent mode off for good, set `agent=false` in the configuration file. When agent mode is turned on because an agent is detected, the CLI prints a notice to the standard error that explains how to turn it off. :::{warning} A script that an agent runs inherits the environment of the agent. If the script writes the output of the CLI to a file or reads it through a pipe, for example with `> result.csv` or `| gzip > result.csv.gz`, the output is shortened in agent mode while the exit status is still `0`. Set `--output-format` or `--no-agent`, or the environment variable `TRINO_AGENT_MODE=0`, in scripts that need the complete result. ::: In agent mode, the CLI behaves as follows: * The default output format is `AGENT`, which prints a compact Markdown table. The type of each column is part of the header. Set `--output-format` to another format on the command line to keep the other agent mode behavior with that format. The limits that follow apply only to the `AGENT` format. ```text |nationkey:bigint|name:varchar|regionkey:bigint| |---|---|---| |0|ALGERIA|0| |1|ARGENTINA|1| |2|BRAZIL|1| ``` * A result with up to 1000 rows and 10000 bytes, including the header, is printed in full. A larger result is cut to the first and last 20 rows with a marker such as `…(+1460 rows)` between them. When `--agent-max-rows` is below 40, the printed rows are split evenly between the start and the end, with the extra row at the start. The byte limit can cut the output to fewer rows, but the first row is printed even when it alone is over the limit. Values and column headers longer than 500 characters are cut and end with a marker such as `…(+4500 chars)`. Use the `--agent-max-rows`, `--agent-max-bytes`, and `--agent-max-cell-width` options to change the limits. A value of `0` removes a limit. When both the row and the byte limit are removed, the rows are printed while they are read and not kept in memory. * In values, the characters `\`, `|`, carriage return and line feed are written as `\\`, `\|`, `\r` and `\n`, so that a line break can be told from the text `\n`. * A result of one column and one row with a value that has line breaks, such as the plan from `EXPLAIN` or the statement from `SHOW CREATE TABLE`, is printed as that text and not as a table. The text is not escaped and the cell width does not apply, and the byte limit cuts it with a marker such as `…(+4500 chars)`. * The CLI cancels the query after it has read 100000 rows past the point where the output was cut. The footer then states `at least` the number of rows read, and the exit status is `0`. A query that runs in a transaction is not cancelled, because that fails the transaction. Its remaining rows are read and counted, and the footer has the number of rows. * A result of a query that failed or was cancelled has the footer `(incomplete: 10 rows received before the query ended)` and no hash, and the error is reported. * A result with no rows, with 10 or more rows, or that was cut ends with a footer that has the number of rows and a hash of the complete result. A result with fewer rows ends with a blank line, which separates the tables of statements that run in one command. The footer of a cut result names the options that print every row, only for the limits that the result went over. The hash does not depend on the order of the rows. It covers the column names and types and the rows that are not printed, so a program can use it to check whether two results are the same. It distinguishes a `NULL` value from the text `'NULL'`, but it compares values inside arrays, maps, and rows as they are printed. ```text (1500 rows, showing the first 20 and last 20, --agent-max-rows 0 --agent-max-bytes 0 for all, hash: a7553ab5cf51bd45) ``` * Errors are printed to the standard error as one line of JSON. A query failure has the query ID, the error name, type and code, the SQL state, the message, and the location of the error in the query. Other errors, such as a server that is not reachable, only have a message. Warnings are not changed. Errors in the command line options, such as an unknown option, are reported before agent mode is known and keep their regular text message. ```json {"type":"error","query_id":"20200707_170726_00030_2iup9","error_name":"COLUMN_NOT_FOUND","error_type":"USER_ERROR","error_code":47,"sql_state":"42000","message":"line 1:25: Column 'region' cannot be resolved","location":{"line":1,"column":25}} ``` * Instead of the progress bar, the CLI prints a line to the standard error every 5 seconds while a query runs. The `--progress` option replaces these lines with the regular progress output of the CLI. ```text progress: query_id=20200707_170726_00030_2iup9 state=RUNNING progress=42% elapsed=12s rows=1234567 bytes=34567890 ``` (cli-spooling-protocol)= ## Spooling protocol The Trino CLI automatically uses the spooling protocol to improve throughput for client interactions with higher data transfer demands, if the [](protocol-spooling) is configured on the cluster. Optionally use the `--encoding` option to configure a different desired encoding, compared to the default on the cluster. The available values are `json+zstd` (recommended) for JSON with Zstandard compression, and `json+lz4` for JSON with LZ4 compression, and `json` for uncompressed JSON. The CLI process must have network access to the spooling object storage. (cli-output-format)= ## Output formats The Trino CLI provides the options `--output-format` and `--output-format-interactive` to control how the output is displayed. The available options shown in the following table must be entered in uppercase. The default value is `ALIGNED` in interactive mode, and `CSV` in non-interactive mode. :::{list-table} Output format options :widths: 25, 75 :header-rows: 1 * - Option - Description * - `CSV` - Comma-separated values, each value quoted. No header row. * - `CSV_HEADER` - Comma-separated values, quoted with header row. * - `CSV_UNQUOTED` - Comma-separated values without quotes. * - `CSV_HEADER_UNQUOTED` - Comma-separated values with header row but no quotes. * - `TSV` - Tab-separated values. * - `TSV_HEADER` - Tab-separated values with header row. * - `JSON` - Output rows emitted as JSON objects with name-value pairs. * - `ALIGNED` - Output emitted as an ASCII character table with values. * - `VERTICAL` - Output emitted as record-oriented top-down lines, one per value. * - `AUTO` - Same as `ALIGNED` if output would fit the current terminal width, and `VERTICAL` otherwise. * - `MARKDOWN` - Output emitted as a Markdown table. * - `AGENT` - Output emitted as a compact Markdown table with the column types in the header, limited in size, with a footer for large results. This is the default in [agent mode](cli-agent-mode). * - `NULL` - Suppresses normal query results. This can be useful during development to test a query's shell return code or to see whether it results in error messages. ::: (cli-troubleshooting)= ## Troubleshooting If something goes wrong, you see an error message: ```text $ trino trino> select count(*) from tpch.tiny.nations; Query 20200804_201646_00003_f5f6c failed: line 1:22: Table 'tpch.tiny.nations' does not exist select count(*) from tpch.tiny.nations ``` To view debug information, including the stack trace for failures, use the `--debug` option: ```text $ trino --debug trino> select count(*) from tpch.tiny.nations; Query 20200804_201629_00002_f5f6c failed: line 1:22: Table 'tpch.tiny.nations' does not exist io.trino.spi.TrinoException: line 1:22: Table 'tpch.tiny.nations' does not exist at io.trino.sql.analyzer.SemanticExceptions.semanticException(SemanticExceptions.java:48) at io.trino.sql.analyzer.SemanticExceptions.semanticException(SemanticExceptions.java:43) ... at java.base/java.lang.Thread.run(Thread.java:834) select count(*) from tpch.tiny.nations ```