Project: YugabyteDB (App Definition and Development / Database)
File: presto.md

title: Presto linkTitle: Presto description: Presto menu: preview_integrations: identifier: presto parent: data-discovery weight: 571 type: docs is a distributed SQL query engine optimized for ad-hoc analysis at interactive speed. It supports standard ANSI SQL, including complex queries, aggregations, joins, and window functions. It has a connector architecture to query data from many data sources. This document describes how to set up Presto to query YugabyteDB's YCQL tables. Follow the instructions to run a local YugabyteDB cluster. Test YugabyteDB's Cassandra-compatible API, as so that you can confirm that you have a Cassandra-compatible service running on `localhost:9042`. Ensure that you have created the keyspace and table, and inserted sample data as described there. Detailed steps are documented . The following are the minimal steps for getting started: ```sh $ wget https://repo1.maven.org/maven2/io/prestosql/presto-server/309/presto-server-309.tar.gz ``` ```sh $ tar xvf presto-server-309.tar.gz ``` ```sh $ cd presto-server-309 ``` ```sh $ mkdir etc ``` ```sh $ mkdir etc/catalog ``` ```sh $ mkdir data ``` ```sh $ cat > etc/node.properties ``` ```cfg node.environment=test node.id=ffffffff-ffff-ffff-ffff-ffffffffffff node.data-dir=/Users/<username>/presto-server-309/data ``` Press Ctrl-D after you have pasted the file contents. ```sh $ cat > etc/jvm.config ``` ```cfg -server -Xmx6G -XX:+UseG1GC -XX:G1HeapRegionSize=32M -XX:+UseGCOverheadLimit -XX:+ExplicitGCInvokesConcurrent -XX:+HeapDumpOnOutOfMemoryError -XX:+ExitOnOutOfMemoryError ``` Press Ctrl-D after you have pasted the file contents. ```sh $ cat > etc/config.properties ``` ```cfg coordinator=true node-scheduler.include-coordinator=true http-server.http.port=8080 query.max-memory=4GB query.max-memory-per-node=1GB discovery-server.enabled=true discovery.uri=http://localhost:8080 ``` Press Ctrl-D after you have pasted the file contents. ```sh $ cat > etc/log.properties ``` ```cfg io.prestosql=INFO ``` Press Ctrl-D after you have pasted the file contents. Create the Cassandra catalog properties file in `etc/catalog` directory. Detailed instructions are . ```sh $ cat > etc/catalog/cassandra.properties ``` ```cfg connector.name=cassandra cassandra.contact-points=127.0.0.1 ``` Press Ctrl-D after you have pasted the file contents. ```sh $ cd ~/presto-server-309/bin ``` ```sh $ wget https://repo1.maven.org/maven2/io/prestosql/presto-cli/309/presto-cli-309-executable.jar ``` Rename the JAR file to `presto`. It is meant to be a self-running binary. ```sh $ mv presto-cli-309-executable.jar presto && chmod +x presto ``` ```sh $ cd ~/presto-server-309 ``` To run in foreground mode: ```sh $ ./bin/launcher run ``` To run in background mode: ```sh $ ./bin/launcher start ``` Use the presto CLI to run ad-hoc queries: ```sh $ ./bin/presto --server localhost:8080 --catalog cassandra --schema default ``` Start using `myapp`: ```sql presto:default> use myapp; ``` ```output USE ``` Show the tables available: ```sql presto:myapp> show tables; ``` ```output Table stock_market (1 row) ``` Describe a particular table: ```sql presto:myapp> describe stock_market; ``` ```output Column | Type | Extra | Comment ++-+ stock_symbol | varchar | | ts | varchar | | current_price | real | | (3 rows) ``` ```sql presto:myapp> select * from stockmarket where stocksymbol = 'AAPL'; ``` ```output stocksymbol | ts | currentprice --++ AAPL | 2017-10-26 09:00:00 | 157.41 AAPL | 2017-10-26 10:00:00 | 157.0 (2 rows) ``` ```sql presto:myapp> select stocksymbol, avg(currentprice) from stockmarket group by stocksymbol; ``` ```output stocksymbol | col1 --+ GOOG | 972.235 AAPL | 157.205 FB | 170.365 (3 rows) ```