CLI

How to Get the Presto CLI Tool

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 executable.

CLI | Get started in 4 steps:

  1. Choose one of three ways to install it: 

If you use Docker, install the Ahana sandbox in Docker

If you have a Mac and use brew, simply run “brew install presto”

2. Download only the presto-cli tar file from https://prestodb.io/download.html (this will work on any OS that has java installed) 

Note that the first two options will install PrestoDB server as well.  All three options will give you the presto-cli executable jar client that you can use to connect to any Presto cluster – including Ahana Cloud for Presto of course.

3. Next check your Ahana Cloud console for the Presto cluster endpoint URL. You will find it in the Cluster Connection details:

Presto CLI

4. And now connect using that URL. Here’s an example that connects you to Ahana’s integrated querylog.

MacBook$ presto --server https://MyClusterName.app --schema public --catalog ahana_querylog
presto:public> select * from querylog;

      type      | cluster_name |           ts            | seq |    user     | query 
----------------+--------------+-------------------------+-----+-------------+------------
 queryCreated   | devtest      | 2020-09-22 13:03:32.000 |   1 | jamesmesney | show catalogs                                                                                                          
 queryCreated   | devtest      | 2020-09-22 13:03:54.000 |   3 | jamesmesney | use ahana_querylog                                                                                                     
 queryCreated   | devtest      | 2020-09-22 13:04:15.000 |   4 | jamesmesney | use ahana_hive                                                                                                         
 queryCreated   | devtest      | 2020-09-22 13:06:28.000 |   5 | jamesmesney | SHOW FUNCTIONS                                                                                                         
 queryCreated   | devtest      | 2020-09-22 13:15:13.000 |   8 | jamesmesney | show catalogs                                                                                                          
 queryCreated   | devtest      | 2020-09-22 13:15:19.000 |  10 | jamesmesney | use ahana_hive                                                                                                         
 queryCompleted | devtest      | 2020-09-22 13:15:19.000 |  11 | jamesmesney | use ahana_hive                                                                                                         
 queryCreated   | devtest      | 2020-09-22 13:15:20.000 |  13 | jamesmesney | SELECT table_name FROM information_schema.tables WHERE table_schema = 'default'                                        
...

One more example to get you started with the integrated tpch data:

MacBook$ presto --schema sf1 --catalog tpch

presto:sf1> show tables;

  Table   

----------

 customer 

 lineitem 

 nation   

 orders   

 part     

 partsupp 

 region   

 supplier 

(8 rows)

presto:sf1> select count(*) from orders where orderdate < date '2020-09-01';

  _col0  

---------

 1500000 

(1 row)

If you have a Windows machine and have downloaded the presto cli jar file from https://prestodb.io/download.html and having trouble running it try this (replace ‘nnn’ with the your version):

c:\ java -jar presto-cli-0.nnn-executable.jar --server <host:port> --catalog <catalog_name> --schema <schema_name> --user <user_name> --<password>

Related Articles

5 Components of Data Warehouse Architecture

In this article we’ll look at the contextual requirements of a data warehouse, which are the five components of a data warehouse. Learn more about the different components.

Data Warehouse: A Comprehensive Guide

A data warehouse is a data repository that is typically used for analytic systems and Business Intelligence tools. Learn more data warehouses in this article.

What is an Open Data Lake in the Cloud?

The Open Data Lake in the cloud is the solution to the massive data problem. Many companies are adopting that architecture because of better price-performance, scale, and non-proprietary architecture.