Last Updated: 2024-05-13
Welcome to the beginner's guide to Trino! Trino is a powerful distributed SQL query engine designed for running fast analytic queries against large datasets. Whether you're a data analyst, data scientist, or software engineer, Trino can help you query and analyze your data efficiently, without the need to move or copy it.
In this tutorial, you'll get a taste of Trino without having to worry about a complicated setup process. You will begin by connecting to a configured Trino demo environment, then move on to running basic queries and viewing query details in the Trino web UI.
Once you've completed this tutorial, you will be able to:
The Trino project provides a Docker container that allows you to easily start up a configured demo environment of Trino. With a few simple terminal commands, you can have Trino up and running to begin your exploration.
You can use the command shell of your choice for this tutorial. It was tested on a Mac, so the print screens you see will show a terminal window.
trino-trial
. It will also map the port from the container to the port on your workstation. docker run -d -p 8080:8080 --name trino-trial trinodb/trino
The next command will connect the Docker container with the Trino image to the Trino server.
docker exec -it trino-trial trino
trino>
prompt.
Trino is an ANSI-SQL compliant engine. This makes it easy to query all of your data sources with the same language.
The Trino server used in this tutorial contains some sample TPC-H data which you'll query in this section.
A Trino catalog contains schemas and references a data source via a connector. You can easily view available catalogs with the SHOW CATALOGS
command.
SHOW CATALOGS;
In Trino, catalogs have a hierarchical structure in which a catalog can contain one or more schemas, and each of those schemas can contain one or more tables. You can use SQL to list the schemas and tables.
tpch
catalog:SHOW SCHEMAS IN tpch;
tpch
represent scale factors for the data. Run the following SQL to set your Trino session to use the tpch.sf1
schema:USE tpch.sf1;
tpch.sf1
schema:SHOW TABLES;
customer
table Let's run a query that returns the entire table so that you can learn to navigate the results in the CLI.
SELECT * FROM customer;
Notice the information that Trino provides at the end of each query. The number of nodes tells you how many workers were used to process the query. Ours used 1 worker. You'll also see the execution time, number of rows processed, and the speed at which they were processed.
The Trino CLI provides some basic statistics for each query, but if you want to get even more detailed information, the Trino web UI is the place to go. There you'll find information such as the version of Trino running, the environment in which it is running, and how long the cluster has been active. Additionally, you'll be able to view active queries, query history, and the number of queued or blocked queries.
After you log in to the Trino web UI, you are on a page that shows basic information about your Trino cluster.
The list of finished queries provides plenty of detailed information for each query. You can dig even deeper into each query by clicking on the Query ID link.
Congratulations! You have reached the end of this tutorial, and the end of this stage of your journey.
Now that you've learned a bit about how to use Trino, we encourage you to run your own queries in the Trino CLI, using your own SQL knowledge.
And if you're looking for an even easier way to use Trino in a fully-managed environment, check out Starburst Galaxy.
At Starburst, we believe in continuous learning. This tutorial provides the foundation for further training available on this platform, and you can return to it as many times as you like. Future tutorials will make use of the concepts used here.
Starburst has lots of other tutorials to help you get up and running quickly. Each one breaks down an individual problem and guides you to a solution using a step-by-step approach to learning.
Visit the Tutorials section to view the full list of tutorials and keep moving forward on your journey!