### Examples Source: https://github.com/prestodb/prestodb.github.io/blob/source/website/static/docs/0.291/_sources/sql/start-transaction.rst.txt Examples of how to use the START TRANSACTION command with different options. ```sql START TRANSACTION; START TRANSACTION ISOLATION LEVEL REPEATABLE READ; START TRANSACTION READ WRITE; START TRANSACTION ISOLATION LEVEL READ COMMITTED, READ ONLY; START TRANSACTION READ WRITE, ISOLATION LEVEL SERIALIZABLE; ``` -------------------------------- ### IO Plan and JSON Format Example Source: https://github.com/prestodb/prestodb.github.io/blob/source/website/static/docs/0.291/_static/sql/explain.rst An example showing how to get the IO plan in JSON format for an INSERT statement. ```none presto:hive> EXPLAIN (TYPE IO, FORMAT JSON) INSERT INTO test_nation SELECT * FROM nation WHERE regionkey = 2; Query Plan ----------------------------------- { "inputTableColumnInfos" : [ { "table" : { "catalog" : "hive", "schemaTable" : { "schema" : "tpch", "table" : "nation" } }, "columns" : [ { "columnName" : "regionkey", "type" : "bigint", "domain" : { "nullsAllowed" : false, ``` -------------------------------- ### JVM Config Example Source: https://github.com/prestodb/prestodb.github.io/blob/source/website/static/docs/0.291/_sources/installation/deployment.rst.txt A recommended starting point for the etc/jvm.config file. ```none -server -Xmx16G -XX:+UseG1GC -XX:G1HeapRegionSize=32M -XX:+UseGCOverheadLimit -XX:+ExplicitGCInvokesConcurrent -XX:+HeapDumpOnOutOfMemoryError -XX:+ExitOnOutOfMemoryError ``` -------------------------------- ### Start Kafka Server Source: https://github.com/prestodb/prestodb.github.io/blob/source/website/static/docs/0.291/_sources/connector/kafka-tutorial.rst.txt Starts the Kafka server. ```none $ bin/kafka-server-start.sh config/server.properties [2013-04-22 15:01:47,028] INFO Verifying properties (kafka.utils.VerifiableProperties) [2013-04-22 15:01:47,051] INFO Property socket.send.buffer.bytes is overridden to 1048576 (kafka.utils.VerifiableProperties) ... ``` -------------------------------- ### Start Presto Source: https://github.com/prestodb/prestodb.github.io/blob/source/website/static/docs/0.291/_sources/connector/kafka-tutorial.rst.txt Command to start the Presto server. ```bash $ bin/launcher start ``` -------------------------------- ### GET /v1/node Example Response Source: https://github.com/prestodb/prestodb.github.io/blob/source/website/static/docs/0.291/_sources/rest/node.rst.txt Example response for the GET /v1/node endpoint, showing a single node with no failures. ```http HTTP/1.1 200 OK Vary: Accept Content-Type: text/javascript [ { "uri":"http://10.209.57.156:8080", "recentRequests":25.181940555111073, "recentFailures":0.0, "recentSuccesses":25.195472984170983, "lastRequestTime":"2013-12-22T13:32:44.673-05:00", "lastResponseTime":"2013-12-22T13:32:44.677-05:00", "age":"14155.28ms", "recentFailureRatio":0.0, "recentFailuresByType":{} } ] ``` -------------------------------- ### GET /v1/node Example Response with Errors Source: https://github.com/prestodb/prestodb.github.io/blob/source/website/static/docs/0.291/_sources/rest/node.rst.txt Example response for the GET /v1/node endpoint, showing a node experiencing errors. ```http HTTP/1.1 200 OK Vary: Accept Content-Type: text/javascript [ { "age": "4.45m", "lastFailureInfo": { "message": "Connect Timeout", "stack": [ "org.eclipse.jetty.io.ManagedSelector$ConnectTimeout.run(ManagedSelector.java:683)", .... "java.lang.Thread.run(Thread.java:745)" ], "suppressed": [], "type": "java.net.SocketTimeoutException" }, "lastRequestTime": "2017-08-05T11:53:00.647Z", "lastResponseTime": "2017-08-05T11:53:00.647Z", "recentFailureRatio": 0.47263053472046446, "recentFailures": 2.8445543205610617, "recentFailuresByType": { "java.net.SocketTimeoutException": 2.8445543205610617 }, "recentRequests": 6.018558073577414, "recentSuccesses": 3.1746446343010297, "uri": "http://172.19.0.3:8080" } ] ``` -------------------------------- ### Show Tables Source: https://github.com/prestodb/prestodb.github.io/blob/source/website/static/docs/0.291/_static/connector/kafka-tutorial.rst SQL command to list tables in the current catalog and schema. ```sql presto:tpch> SHOW TABLES; Table ---------- customer lineitem nation orders part partsupp region supplier (8 rows) ``` -------------------------------- ### GET /v1/node/failed Example Response Source: https://github.com/prestodb/prestodb.github.io/blob/source/website/static/docs/0.291/_sources/rest/node.rst.txt Example response for the GET /v1/node/failed endpoint, listing nodes that have failed the last heartbeat check. ```http HTTP/1.1 200 OK Vary: Accept Content-Type: text/javascript [ { "age": "1.37m", "lastFailureInfo": { "message": "Connect Timeout", "stack": [ "org.eclipse.jetty.io.ManagedSelector$ConnectTimeout.run(ManagedSelector.java:683)", .... "java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)", "java.lang.Thread.run(Thread.java:745)" ], "suppressed": [], "type": "java.net.SocketTimeoutException" }, "lastRequestTime": "2017-08-05T11:52:42.647Z", "lastResponseTime": "2017-08-05T11:52:42.647Z", "recentFailureRatio": 0.22498784153043677, "recentFailures": 20.11558290058638, "recentFailuresByType": { "java.net.SocketTimeoutException": 20.11558290058638 }, "recentRequests": 89.40742203558189, "recentSuccesses": 69.30583024727453, "uri": "http://172.19.0.3:8080" } ] ``` -------------------------------- ### json_array_length function example Source: https://github.com/prestodb/prestodb.github.io/blob/source/website/static/docs/0.291/_sources/functions/json.rst.txt Example showing how to get the length of a JSON array. ```sql SELECT json_array_length('[1, 2, 3]'); ``` -------------------------------- ### Start Presto CLI Source: https://github.com/prestodb/prestodb.github.io/blob/source/website/static/docs/0.291/_sources/connector/kafka-tutorial.rst.txt Command to start the Presto CLI with specific catalog and schema. ```bash $ ./presto --catalog kafka --schema tpch ``` -------------------------------- ### map_top_n_values example Source: https://github.com/prestodb/prestodb.github.io/blob/source/website/static/docs/0.291/_sources/functions/map.rst.txt Example of using map_top_n_values to get top values from a map. ```sql SELECT map_top_n_values(map(ARRAY['a', 'b', 'c'], ARRAY[1, 2, 3]), 2) --- [3, 2] ``` -------------------------------- ### map_keys_by_top_n_values example Source: https://github.com/prestodb/prestodb.github.io/blob/source/website/static/docs/0.291/_sources/functions/map.rst.txt Example of using map_keys_by_top_n_values to get top keys by value. ```sql SELECT map_top_n_keys_by_value(map(ARRAY['a', 'b', 'c'], ARRAY[2, 1, 3]), 2) --- ['c', 'a'] ``` -------------------------------- ### Start ZooKeeper and Kafka Server Source: https://github.com/prestodb/prestodb.github.io/blob/source/website/static/docs/0.291/connector/kafka-tutorial.html Commands to start ZooKeeper and the Kafka server. ```bash $ bin/zookeeper-server-start.sh config/zookeeper.properties [2013-04-22 15:01:37,495] INFO Reading configuration from: config/zookeeper.properties (org.apache.zookeeper.server.quorum.QuorumPeerConfig) ... ``` ```bash $ bin/kafka-server-start.sh config/server.properties [2013-04-22 15:01:47,028] INFO Verifying properties (kafka.utils.VerifiableProperties) [2013-04-22 15:01:47,051] INFO Property socket.send.buffer.bytes is overridden to 1048576 (kafka.utils.VerifiableProperties) ... ``` -------------------------------- ### Example Output Source: https://github.com/prestodb/prestodb.github.io/blob/source/website/static/docs/0.291/_static/sql/show-create-table.rst Example output of the SHOW CREATE TABLE command, showing the CREATE TABLE statement. ```none Create Table ----------------------------------------- CREATE TABLE tpch.sf1.orders ( orderkey bigint, orderstatus varchar, totalprice double, orderdate varchar ) WITH ( format = 'ORC', partitioned_by = ARRAY['orderdate'] ) (1 row) ``` -------------------------------- ### ip_subnet_max function examples Source: https://github.com/prestodb/prestodb.github.io/blob/source/website/static/docs/0.291/_static/functions/ip.rst Examples illustrating the use of ip_subnet_max to get the largest IP address in a subnet. ```sql SELECT ip_subnet_max(IPPREFIX '192.64.0.0/9'); -- {192.127.255.255} SELECT ip_subnet_max(IPPREFIX '2001:0db8:85a3:0001:0001:8a2e:0370:7334/48'); -- {2001:db8:85a3:ffff:ffff:ffff:ffff:ffff} ``` -------------------------------- ### Show Tables Example Source: https://github.com/prestodb/prestodb.github.io/blob/source/website/static/docs/0.291/connector/pinot.html Example command to show all tables in a Pinot cluster. ```sql SHOW TABLES from mypinotcluster.default OR: SHOW TABLES from mypinotcluster.foo ``` -------------------------------- ### ip_prefix_subnets function examples Source: https://github.com/prestodb/prestodb.github.io/blob/source/website/static/docs/0.291/_static/functions/ip.rst Examples for ip_prefix_subnets to get subnets of a given IP prefix with a specified prefix length. ```sql SELECT IP_PREFIX_SUBNETS(IPPREFIX '192.168.1.0/24', 25); -- [{192.168.1.0/25}, {192.168.1.128/25}] SELECT IP_PREFIX_SUBNETS(IPPREFIX '2a03:2880:c000::/34', 36); -- [{2a03:2880:c000::/36}, {2a03:2880:d000::/36}, {2a03:2880:e000::/36}, {2a03:2880:f000::/36}] ``` -------------------------------- ### Hash counts example Source: https://github.com/prestodb/prestodb.github.io/blob/source/website/static/docs/0.291/_static/functions/setdigest.rst Example of getting a map of Murmur3Hash128 hashed values and their counts from a MinHash structure. ```sql SELECT hash_counts(x) ``` -------------------------------- ### Start ZooKeeper Source: https://github.com/prestodb/prestodb.github.io/blob/source/website/static/docs/0.291/_sources/connector/kafka-tutorial.rst.txt Starts the ZooKeeper server, which is required for Kafka. ```none $ bin/zookeeper-server-start.sh config/zookeeper.properties [2013-04-22 15:01:37,495] INFO Reading configuration from: config/zookeeper.properties (org.apache.zookeeper.server.quorum.QuorumPeerConfig) ... ``` -------------------------------- ### Example HTTP Request for Statement Source: https://github.com/prestodb/prestodb.github.io/blob/source/website/static/docs/0.291/_sources/rest/statement.rst.txt This snippet shows an example HTTP GET request to retrieve the status or results of a submitted statement. ```http GET /v1/statement/20140108_110629_00011_dk5x2/1 HTTP/1.1 Host: localhost:8001 User-Agent: StatementClient/0.55-SNAPSHOT ``` -------------------------------- ### Example HTTP Connector Configuration Source: https://github.com/prestodb/prestodb.github.io/blob/source/website/static/docs/0.291/_sources/release/release-0.54.rst.txt Configuration properties for mounting the example-http connector as the 'example' catalog. ```none connector.name=example-http metadata-uri=http://s3.amazonaws.com/presto-example/v1/example-metadata.json ``` -------------------------------- ### Starting Presto Server Source: https://github.com/prestodb/prestodb.github.io/blob/source/website/static/docs/0.291/_sources/installation/deployment.rst.txt Command to start the Presto server after configuration. ```bash ./bin/launcher start ``` -------------------------------- ### Example Query Response Source: https://github.com/prestodb/prestodb.github.io/blob/source/website/static/docs/0.291/rest/query.html This is an example JSON response for the GET /v1/query/{queryId} endpoint, showing detailed statistics about a finished query. ```json { "queryId" : "20131229_211533_00017_dk5x2", "session" : { "user" : "tobrien", "source" : "presto-cli", "catalog" : "jmx", "schema" : "jmx", "remoteUserAddress" : "173.15.79.89", "userAgent" : "StatementClient/0.55-SNAPSHOT", "startTime" : 1388351852026 }, "state" : "FINISHED", "self" : "http://10.193.207.128:8080/v1/query/20131229_211533_00017_dk5x2", "fieldNames" : [ "name" ], "query" : "select name from \"java.lang:type=runtime\"", "queryStats" : { "createTime" : "2013-12-29T16:17:32.027-05:00", "executionStartTime" : "2013-12-29T16:17:32.086-05:00", "lastHeartbeat" : "2013-12-29T16:17:44.561-05:00", "endTime" : "2013-12-29T16:17:32.152-05:00", "elapsedTime" : "125.00ms", "queuedTime" : "1.31ms", "analysisTime" : "4.84ms", "totalTasks" : 2, "runningTasks" : 0, "completedTasks" : 2, "totalDrivers" : 2, "queuedDrivers" : 0, "runningDrivers" : 0, "completedDrivers" : 2, "totalMemoryReservation" : "0B", "totalScheduledTime" : "5.84ms", "totalCpuTime" : "710.49us", "totalBlockedTime" : "27.38ms", "rawInputDataSize" : "27B", "rawInputPositions" : 1, "processedInputDataSize" : "32B", "processedInputPositions" : 1, "outputDataSize" : "32B", "outputPositions" : 1 }, "outputStage" : { } } ``` -------------------------------- ### Show Tables in Presto Source: https://github.com/prestodb/prestodb.github.io/blob/source/website/static/docs/0.291/_sources/connector/kafka-tutorial.rst.txt Presto CLI command to list tables in the current schema. ```sql SHOW TABLES; ``` -------------------------------- ### Download twistr tool Source: https://github.com/prestodb/prestodb.github.io/blob/source/website/static/docs/0.291/_sources/connector/kafka-tutorial.rst.txt Command to download the twistr tool, used for setting up a live Twitter feed. ```none $ curl -o twistr https://repo1.maven.org/maven2/de/softwareforge/twistr_kafka_0811/1.2/twistr_kafka_0811-1.2.sh $ chmod 755 twistr ``` -------------------------------- ### find_first_index with index Source: https://github.com/prestodb/prestodb.github.io/blob/source/website/static/docs/0.291/_sources/functions/array.rst.txt Examples of using find_first_index with a starting index to search within an array. ```sql SELECT find_first(ARRAY[3, 4, 5, 6], 2, x -> x > 0); -- 2 SELECT find_first(ARRAY[3, 4, 5, 6], -2, x -> x > 0); -- 3 SELECT find_first(ARRAY[3, 4, 5, 6], 2, x -> x < 4); -- NULL SELECT find_first(ARRAY[3, 4, 5, 6], -2, x -> x > 5); -- NULL ``` -------------------------------- ### Show Tables Source: https://github.com/prestodb/prestodb.github.io/blob/source/website/static/docs/0.291/connector/kafka-tutorial.html Presto CLI command to list tables in the current schema. ```sql presto:tpch> SHOW TABLES; ``` -------------------------------- ### find_first with index Source: https://github.com/prestodb/prestodb.github.io/blob/source/website/static/docs/0.291/_sources/functions/array.rst.txt Examples of using find_first with a starting index to search within an array. ```sql SELECT find_first(ARRAY[3, 4, 5, 6], 2, x -> x > 0); -- 4 SELECT find_first(ARRAY[3, 4, 5, 6], -2, x -> x > 0); -- 5 SELECT find_first(ARRAY[3, 4, 5, 6], 2, x -> x < 4); -- NULL SELECT find_first(ARRAY[3, 4, 5, 6], -2, x -> x > 5); -- NULL ``` -------------------------------- ### Create an empty password file Source: https://github.com/prestodb/prestodb.github.io/blob/source/website/static/docs/0.291/_sources/security/password-file.rst.txt Create an empty password file to get started. ```none touch password.db ``` -------------------------------- ### JVM Config Example Source: https://github.com/prestodb/prestodb.github.io/blob/source/website/static/docs/0.291/_sources/router/deployment.rst.txt An example configuration for the Java Virtual Machine settings. ```none -ea -XX:+UseG1GC -XX:G1HeapRegionSize=32M -XX:+UseGCOverheadLimit -XX:+ExplicitGCInvokesConcurrent -Xmx12G ```