Running Presto queries#
The Presto CLI provides a terminal-based interactive shell for running queries. The CLI is a self-executing JAR file, which means it acts like a normal UNIX executable.
To run a query via the Presto CLI:
presto-cliand copy it to the location you want to run it from. This location may be any node that has network access to the coordinator.
Rename the artifact to
prestoand make it executable, substituting your version of Presto for “version”:
$ mv presto-cli-<version>-executable.jar presto $ chmod +x presto
Presto must run with at least Java 11, so if another version is default on
your cluster, you will need to explicitly specify the Java 11 executable.
<path_to_java_11_executable> -jar presto. It may be
helpful to add an alias for the Presto CLI:
alias presto='<path_to_java_11_executable> -jar <path_to_presto>'.
presto-adminconfigures a TPC-H catalog, which generates TPC-H data on-the-fly. Using this catalog, issue the following commands to run your first Presto query:
$ ./presto --catalog tpch --schema tiny $ select count(*) from lineitem;
The above command assumes that you installed the Presto CLI on the coordinator, and that the Presto server is on port 8080. If either of these are not the case, then specify the server location in the command:
$ ./presto --server <host_name>:<port_number> --catalog tpch --schema tiny