4.5. Querying Presto

Command Line Interface

1. Connect to the Edge Node

Follow the steps from Connect to the Presto Edge Node via SSH to successfully connect to your desired Presto cluster.

2. Open the Presto CLI

Type the following command to access the Presto CLI and press enter. Your cursor will skip to the next line, preceded by presto >.

presto-cli

3. Catalogs and Schemas

View your catalogs and schemas via the following commands. Note, replace hive with your desired catalog.

show catalogs;
show schemas in hive;

4. Run Queries

Type your SQL query into the Presto CLI. For reference, view the SQL SELECT statement below. All HDInsight clusters have a default sample Hive table called hivesampletable. Let’s query from this.

presto:default> show tables in hive.default;
      Table
-----------------
 hivesampletable
(1 row)

presto:default> select count(*) from hive.default.hivesampletable;
 _col0
-------
 59793
(1 row)

Query 20180923_035859_00011_mim7z, FINISHED, 1 node
Splits: 18 total, 18 done (100.00%)
0:02 [59.8K rows, 4.73MB] [36.6K rows/s, 2.9MB/s]

ODBC & JDBC Drivers

The open source Presto JDBC driver can be used with Presto on Azure. This can be downloaded from Starburst’s download page. Additionally, Starburst provides Enterprise ODBC and JDBC drivers, available for Windows, Mac, and Linux platforms for its Enterprise customers. Please refer to the following link:

https://www.starburstdata.com/download-starburst-enterprise-distribution-of-presto/