Docs
uhadoop
Developer Guide
Presto Development Guide

Presto Development Guide

Introduction to Presto

Presto is an open-source distributed SQL query engine, suitable for interactive analysis queries of GB to PB level data.

It supports online query and data integration of various source data such as Hive, Cassandra, and relational databases, and is a powerful tool for fast interactive analysis of large-scale commercial data warehouses.

Table operations in hive-cli

Choose to test on the master1 node here

  1. Open hive-cli
[root@uhadoop-xxxxxxxx-master1 hadoop]# hive
  1. View the list of databases in hive
hive> show databases;
  1. Create a new test database
hive> create schema test;
  1. Add a new table table_one to the test library
hive> create table test.table_one(name string);
  1. View all tables in the test library
hive> show tables from test;
  1. Insert data into the table_one table in the test database
hive> insert into test.table_one values ('name1'),('name2'),('name3');
  1. Query table_one table data in hive-cli.
hive> select * from test.table_one;
OK
name1
name2
name3
  1. Exit hive-cli
hive> quit;

Table operations in presto-cli

  1. Open presto-cli
[root@uhadoop-xxxxxxxx-core1 hadoop]# presto-cli --server uhadoop-xxxxxx-master1:28080 --catalog hive --schema test
presto:test>
  1. View all library information under hive in presto-cli
presto:test> show schemas from hive;
  1. View the table list of the test database under hive in presto-cli
presto:test> show tables from test;
  1. Query data in hive table under presto-cli.
presto:test> select * from test.table_one;
 name
-------
 name1
 name2
 name3
(3 rows)
  1. Create table operation directly in hive catalog under presto-cli.
presto:test> create table test.presto_table2(name varchar);
  1. Direct insert operation in presto-cli
presto:test> insert into test.presto_table2 values('myname1'),('myname2');
  - Query the result of the previous insertion:
presto:test> select * from test.presto_table2;
  name
---------
 myname1
 myname2
(2 rows)
  - Exit presto-cli
presto:test> exit;

Call rest-api to view the status of the presto cluster

curl http://uhadoop-xxxxxxxx-master1:28080/v1/cluster

Return:

{
    "runningQueries":0,
    "blockedQueries":0,
    "queuedQueries":0,
    "activeWorkers":3,
    "runningDrivers":0,
    "reservedMemory":0.0,
    "totalInputRows":88,
    "totalInputBytes":2061,
    "totalCpuTimeSecs":1
}