### Install Preview Web UI Dependencies Source: https://github.com/trinodb/trino/blob/master/core/trino-web-ui/src/main/resources/webapp-preview/README.md Navigate to the webapp-preview directory and run `npm install` to install the necessary frontend dependencies. ```bash cd core/trino-web-ui/src/main/resources/webapp-preview npm install ``` -------------------------------- ### Call Example Procedure Source: https://github.com/trinodb/trino/blob/master/docs/src/main/sphinx/connector/delta-lake.md Demonstrates how to call a procedure in the example catalog. ```sql CALL examplecatalog.system.example_procedure() ``` -------------------------------- ### Example Kubernetes Deployment Status Output Source: https://github.com/trinodb/trino/blob/master/docs/src/main/sphinx/installation/kubernetes.md An example of the expected output from the 'kubectl get all' command, showing the status of Trino coordinator and worker pods, services, deployments, and replica sets. ```text NAME READY STATUS RESTARTS AGE pod/example-trino-cluster-coordinator-bfb74c98d-rnrxd 1/1 Running 0 161m pod/example-trino-cluster-worker-76f6bf54d6-hvl8n 1/1 Running 0 161m pod/example-trino-cluster-worker-76f6bf54d6-tcqgb 1/1 Running 0 161m NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE service/example-trino-cluster ClusterIP 10.96.25.35 8080/TCP 161m NAME READY UP-TO-DATE AVAILABLE AGE deployment.apps/example-trino-cluster-coordinator 1/1 1 1 161m deployment.apps/example-trino-cluster-worker 2/2 2 2 161m NAME DESIRED CURRENT READY AGE replicaset.apps/example-trino-cluster-coordinator-bfb74c98d 1 1 1 161m replicaset.apps/example-trino-cluster-worker-76f6bf54d6 2 2 2 161m ``` -------------------------------- ### Example Invocations of to_one_hundred Function Source: https://github.com/trinodb/trino/blob/master/docs/src/main/sphinx/udf/sql/loop.md These examples show how to call the to_one_hundred SQL function with different starting values and step sizes to observe the returned count. ```sql SELECT to_one_hundred(90, 1); --10 ``` ```sql SELECT to_one_hundred(0, 5); --20 ``` ```sql SELECT to_one_hundred(12, 3); -- 30 ``` -------------------------------- ### System Connector Usage Examples Source: https://github.com/trinodb/trino/blob/master/docs/src/main/sphinx/connector/system.md Examples of how to interact with the System connector using SQL. ```APIDOC ## System Connector Usage Examples ### Description Demonstrates common SQL queries to interact with the System connector. ### Show Schemas List all available schemas within the `system` catalog. ```sql SHOW SCHEMAS FROM system; ``` ### Show Tables List tables within a specific schema, for example, the `runtime` schema. ```sql SHOW TABLES FROM system.runtime; ``` ### Query Table Select all data from a table, such as the `nodes` table in the `runtime` schema. ```sql SELECT * FROM system.runtime.nodes; ``` ### Kill Query Execute the `kill_query` procedure to terminate a running query. #### Parameters - **query_id** (varchar) - Required - The ID of the query to kill. - **message** (varchar) - Required - A message explaining why the query is being killed. ```sql CALL system.runtime.kill_query(query_id => '20151207_215727_00146_tx3nr', message => 'Using too many resources'); ``` ``` -------------------------------- ### Create Table Examples Source: https://github.com/trinodb/trino/blob/master/docs/src/main/sphinx/sql/create-table.md Various examples demonstrating table creation, including conditional creation, comments, default values, and the LIKE clause. ```sql CREATE TABLE orders ( orderkey bigint, orderstatus varchar, totalprice double, orderdate date ) WITH (format = 'ORC') ``` ```sql CREATE TABLE IF NOT EXISTS orders ( orderkey bigint, orderstatus varchar, totalprice double COMMENT 'Price in cents.', orderdate date, status varchar DEFAULT 'created' ) COMMENT 'A table to keep track of orders.' ``` ```sql CREATE TABLE bigger_orders ( another_orderkey bigint, LIKE orders, another_orderdate date ) ``` -------------------------------- ### RETURN statement usage examples Source: https://github.com/trinodb/trino/blob/master/docs/src/main/sphinx/udf/sql/return.md Examples showing how to return static values, expressions, and variables from a function. ```sql RETURN 42; RETURN 6 * 7; RETURN x; ``` -------------------------------- ### Start Local HTTP Server for Documentation Source: https://github.com/trinodb/trino/blob/master/docs/README.md Starts a Python HTTP server in the documentation directory to view it locally. Access via http://localhost:4000. ```bash cd docs/target/html/ python3 -m http.server 4000 ``` -------------------------------- ### Start Trino Launcher Source: https://github.com/trinodb/trino/blob/master/docs/src/main/sphinx/connector/kafka-tutorial.md Execute this command to start the Trino server. This is a prerequisite for connecting to Trino and executing queries. ```text $ bin/launcher start ``` -------------------------------- ### Install Docker on GNU/Linux Source: https://github.com/trinodb/trino/blob/master/testing/trino-product-tests/README.md Use this command to install Docker on a GNU/Linux system. ```bash wget -qO- https://get.docker.com/ | sh ``` -------------------------------- ### Connector Pushdown Example (PostgreSQL) Source: https://github.com/trinodb/trino/wiki/Contributor-meetings Illustrates how pushdown capabilities vary across connectors, using PostgreSQL as an example. This is relevant for understanding query optimization strategies. ```java https://trino.io/docs/current/connector/postgresql.html#pushdown ``` -------------------------------- ### Start Trino Container with Tracing Source: https://github.com/trinodb/trino/blob/master/docs/src/main/sphinx/admin/opentelemetry.md Starts the Trino Docker container, connecting it to the 'platform' network and mounting the tracing configuration file. ```shell docker run -d \ --name trino \ --network=platform \ -p 8080:8080 \ --mount type=bind,source=$PWD/config.properties,target=/etc/trino/config.properties \ trinodb/trino:latest ``` -------------------------------- ### Prometheus Connector Configuration Example Source: https://github.com/trinodb/trino/blob/master/docs/src/main/sphinx/connector/prometheus.md Example configuration for mounting the Prometheus connector. Replace properties with your specific Prometheus server details and desired query parameters. ```text connector.name=prometheus prometheus.uri=http://localhost:9090 prometheus.query.chunk.size.duration=1d prometheus.max.query.range.duration=21d prometheus.cache.ttl=30s prometheus.bearer.token.file=/path/to/bearer/token/file prometheus.read-timeout=10s ``` -------------------------------- ### Start Trino as a Daemon Source: https://github.com/trinodb/trino/blob/master/docs/src/main/sphinx/installation/deployment.md Use this command to start the Trino server as a background process (daemon). ```bash bin/launcher start ``` -------------------------------- ### Start Trino CLI Source: https://github.com/trinodb/trino/blob/master/README.md Command to start the Trino CLI client. The JAR path may vary based on the version. ```bash client/trino-cli/target/trino-cli-*-executable.jar ``` -------------------------------- ### Query Example with `query` Function Source: https://github.com/trinodb/trino/blob/master/docs/src/main/sphinx/connector/duckdb.md Use this snippet to query the `example` catalog and select all columns from the `tpch.nation` table using DuckDB's native SQL syntax. ```sql SELECT * FROM TABLE( example.system.query( query => 'SELECT * FROM tpch.nation' ) ); ``` -------------------------------- ### Example Logical Plan Output Source: https://github.com/trinodb/trino/blob/master/docs/src/main/sphinx/sql/explain.md This is an example of the JSON output generated by the EXPLAIN (TYPE LOGICAL, FORMAT JSON) command. It details the query's logical execution plan, including stages, operations, and estimated costs. ```json { "id": "9", "name": "Output", "descriptor": { "columnNames": "[regionkey, _col1]" }, "outputs": [ { "symbol": "regionkey", "type": "bigint" }, { "symbol": "count", "type": "bigint" } ], "details": [ "_col1 := count" ], "estimates": [ { "outputRowCount": "NaN", "outputSizeInBytes": "NaN", "cpuCost": "NaN", "memoryCost": "NaN", "networkCost": "NaN" } ], "children": [ { "id": "145", "name": "RemoteExchange", "descriptor": { "type": "GATHER", "isReplicateNullsAndAny": "", "hashColumn": "" }, "outputs": [ { "symbol": "regionkey", "type": "bigint" }, { "symbol": "count", "type": "bigint" } ], "details": [ ], "estimates": [ { "outputRowCount": "NaN", "outputSizeInBytes": "NaN", "cpuCost": "NaN", "memoryCost": "NaN", "networkCost": "NaN" } ], "children": [ { "id": "4", "name": "Aggregate", "descriptor": { "type": "FINAL", "keys": "[regionkey]", "hash": "" }, "outputs": [ { "symbol": "regionkey", "type": "bigint" }, { "symbol": "count", "type": "bigint" } ], "details": [ "count := count(\"count_0\")" ], "estimates": [ { "outputRowCount": "NaN", "outputSizeInBytes": "NaN", "cpuCost": "NaN", "memoryCost": "NaN", "networkCost": "NaN" } ], "children": [ { "id": "194", "name": "LocalExchange", "descriptor": { "partitioning": "HASH", "isReplicateNullsAndAny": "", "hashColumn": "[$hashvalue]", "arguments": "[\"regionkey\"]" }, "outputs": [ { "symbol": "regionkey", "type": "bigint" }, { "symbol": "count_0", "type": "bigint" }, { "symbol": "$hashvalue", "type": "bigint" } ], "details":[], "estimates": [ { "outputRowCount": "NaN", "outputSizeInBytes": "NaN", "cpuCost": "NaN", "memoryCost": "NaN", "networkCost": "NaN" } ], "children": [ { "id": "200", "name": "RemoteExchange", "descriptor": { "type": "REPARTITION", "isReplicateNullsAndAny": "", "hashColumn": "[$hashvalue_1]" }, "outputs": [ { "symbol": "regionkey", "type": "bigint" }, { "symbol": "count_0", "type": "bigint" }, { "symbol": "$hashvalue_1", "type": "bigint" } ], "details":[], "estimates": [ { "outputRowCount": "NaN", ``` -------------------------------- ### Configure Example HTTP Connector Source: https://github.com/trinodb/trino/blob/master/docs/src/main/sphinx/release/release-0.54.md Mount the example-http connector by creating a catalog properties file. ```text connector.name=example-http metadata-uri=http://s3.amazonaws.com/presto-example/v1/example-metadata.json ``` -------------------------------- ### Run KES Server Source: https://github.com/trinodb/trino/blob/master/plugin/trino-exchange-filesystem/src/test/resources/readme.txt Starts a KES server in development mode. Ensure Docker is installed and running. ```bash docker run -d --name kes-server minio/kes server --dev ``` -------------------------------- ### PostgreSQL Catalog Configuration Source: https://github.com/trinodb/trino/blob/master/docs/src/main/sphinx/connector/postgresql.md Example properties file for configuring a PostgreSQL catalog in Trino. Replace connection details with your specific setup. ```properties connector.name=postgresql connection-url=jdbc:postgresql://example.net:5432/database connection-user=root connection-password=secret ``` -------------------------------- ### SQL Comments Example Source: https://github.com/trinodb/trino/blob/master/docs/src/main/sphinx/language/comments.md Demonstrates single-line comments starting with double dashes and multi-line block comments enclosed in /* */. These comments are ignored by the SQL processor. ```sql -- This is a comment. SELECT * FROM table; -- This comment is ignored. /* This is a block comment that spans multiple lines until it is closed. */ ``` -------------------------------- ### Create Cassandra Keyspace and Table Source: https://github.com/trinodb/trino/blob/master/docs/src/main/sphinx/connector/cassandra.md Use cqlsh to create an example keyspace and a 'users' table in Cassandra. This setup is necessary before interacting with the table via Trino. ```text cqlsh> CREATE KEYSPACE example_keyspace ... WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 }; cqlsh> USE example_keyspace; cqlsh:example_keyspace> CREATE TABLE users ( ... user_id int PRIMARY KEY, ... fname text, ... lname text ... ); ``` -------------------------------- ### Monitor Server Startup Source: https://github.com/trinodb/trino/blob/master/core/docker/README.md Log message indicating the server has successfully initialized. ```text INFO main io.trino.server.Server ======== SERVER STARTED ======== ``` -------------------------------- ### Get local timestamp with subsecond precision Source: https://github.com/trinodb/trino/blob/master/docs/src/main/sphinx/functions/datetime.md Returns the current timestamp with a specified number of subsecond digits. Use this when you need precise time information at the start of a query. ```sql SELECT localtimestamp(6); -- 2020-06-10 15:55:23.383628 ``` -------------------------------- ### Build documentation site with Maven Source: https://github.com/trinodb/trino/blob/master/docs/README.md Uses the Maven wrapper to build the documentation module specifically. ```bash ./mvnw -pl docs clean install ``` -------------------------------- ### Start Kafka server Source: https://github.com/trinodb/trino/blob/master/docs/src/main/sphinx/connector/kafka-tutorial.md Initializes the Kafka broker using the provided server properties. ```text $ 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) ... ``` -------------------------------- ### Active Directory Group Provider Configuration Source: https://github.com/trinodb/trino/blob/master/docs/src/main/sphinx/security/group-mapping.md Example configuration for an Active Directory group provider using a single query, attribute-based approach. This setup is suitable for environments where direct attribute mapping is preferred. ```properties group-provider.name=ldap group-provider.group-case=lower ldap.url=ldaps://ad.example.com:636 ldap.admin-user=cn=admin,dc=example,dc=com ldap.admin-password=your_password ldap.group-name-attribute=cn ldap.user-base-dn=ou=users,dc=example,dc=com ldap.user-search-filter=(sAMAccountName={0}) ldap.use-group-filter=false ldap.user-member-of-attribute=memberOf ``` -------------------------------- ### Prepare and describe a query with parameters Source: https://github.com/trinodb/trino/blob/master/docs/src/main/sphinx/sql/describe-input.md Demonstrates preparing a statement with three parameters and retrieving their metadata. ```sql PREPARE my_select1 FROM SELECT ? FROM nation WHERE regionkey = ? AND name < ?; ``` ```sql DESCRIBE INPUT my_select1; ``` -------------------------------- ### Defining Row Pattern Measures Source: https://github.com/trinodb/trino/blob/master/docs/src/main/sphinx/sql/match-recognize.md The MEASURES clause specifies scalar expressions to compute and return information from matched row sequences. This example defines measures for starting, bottom, and top prices within a match. ```text MEASURES measure_expression AS measure_name [, ...] ``` -------------------------------- ### Example V-Shape Pattern Detection Source: https://github.com/trinodb/trino/blob/master/docs/src/main/sphinx/sql/match-recognize.md This SQL query demonstrates the MATCH_RECOGNIZE clause to detect a V-shape pattern in order prices over time for each customer. It partitions by customer, orders by date, and defines measures for starting, bottom, and top prices. ```sql SELECT * FROM orders MATCH_RECOGNIZE( PARTITION BY custkey ORDER BY orderdate MEASURES A.totalprice AS starting_price, LAST(B.totalprice) AS bottom_price, LAST(U.totalprice) AS top_price ONE ROW PER MATCH AFTER MATCH SKIP PAST LAST ROW PATTERN (A B+ C+ D+) SUBSET U = (C, D) DEFINE B AS totalprice < PREV(totalprice), C AS totalprice > PREV(totalprice) AND totalprice <= A.totalprice, D AS totalprice > PREV(totalprice) ) ``` -------------------------------- ### Connector Factory Creation using Guice Source: https://github.com/trinodb/trino/blob/master/docs/src/main/sphinx/develop/example-http.md The 'create' method in ExampleConnectorFactory configures the connector and uses Guice to instantiate the ExampleConnector. It sets up the Bootstrap application with necessary modules and properties. ```java Bootstrap app = new Bootstrap( new JsonModule(), new ExampleModule(catalogName)); Injector injector = app .doNotInitializeLogging() .setRequiredConfigurationProperties(requiredConfig) .initialize(); return injector.getInstance(ExampleConnector.class); ``` -------------------------------- ### string.substring(start, length) Source: https://github.com/trinodb/trino/blob/master/docs/src/main/sphinx/language/types.md Returns a portion of the string. `start` is 1-based. ```APIDOC ## string.substring(start, length) -> varchar ### Description Returns the `length` code points of `string` beginning at the 1-based index `start`. ### Related [`substring()`](../functions/string.md#substring) ### Example ```sql SELECT 'Trino'.substring(2, 2); -- ri ``` ``` -------------------------------- ### Equivalent PREPARE and EXECUTE Statement Source: https://github.com/trinodb/trino/blob/master/docs/src/main/sphinx/sql/execute-immediate.md This example shows the equivalent of EXECUTE IMMEDIATE with parameters using the PREPARE, EXECUTE, and DEALLOCATE PREPARE statements. ```sql PREPARE statement_name FROM SELECT name FROM nation WHERE regionkey = ? and nationkey < ? EXECUTE statement_name USING 1, 3 DEALLOCATE PREPARE statement_name ``` -------------------------------- ### Start Trino CLI with Default Catalog and Schema Source: https://github.com/trinodb/trino/blob/master/docs/src/main/sphinx/client/cli.md Launches the Trino CLI and sets the default catalog and schema for subsequent queries, simplifying table access. ```text ./trino http://trino.example.com:8080/tpch/tiny ``` -------------------------------- ### Alternation with Quantifier Example Source: https://github.com/trinodb/trino/blob/master/docs/src/main/sphinx/sql/match-recognize.md Example of using alternation with a quantifier in a row pattern. ```text (A | B)* ``` -------------------------------- ### Trino Started Queries Metric Source: https://github.com/trinodb/trino/blob/master/docs/src/main/sphinx/admin/jmx.md Track the count of queries started in the last five minutes. ```jmx trino.execution:name=QueryManager:StartedQueries.FiveMinute.Count ``` -------------------------------- ### JSON Path Syntax Examples Source: https://github.com/trinodb/trino/blob/master/docs/src/main/sphinx/functions/json.md Illustrates the syntax for 'strict' and 'lax' JSON path modes. ```text 'strict ($.price + $.tax)?(@ > 99.9)' ``` ```text 'lax $[0 to 1].floor()?(@ > 10)' ``` -------------------------------- ### Recursive WITH Query Example Source: https://github.com/trinodb/trino/blob/master/docs/src/main/sphinx/sql/select.md A basic example of a recursive WITH query that calculates the sum of a sequence of numbers. ```text WITH RECURSIVE t(n) AS ( VALUES (1) UNION ALL SELECT n + 1 FROM t WHERE n < 4 ) SELECT sum(n) FROM t; ``` -------------------------------- ### Run Preview Web UI in Development Mode Source: https://github.com/trinodb/trino/blob/master/core/trino-web-ui/src/main/resources/webapp-preview/README.md Execute `npm run dev` to start the frontend in development mode, enabling Hot Module Replacement for instant updates. ```bash npm run dev ``` -------------------------------- ### Correlated Scalar Subquery Example Source: https://github.com/trinodb/trino/blob/master/docs/src/main/sphinx/admin/properties-optimizer.md Example of a query that benefits from pushing aggregation through an outer join. ```sql SELECT * FROM item i WHERE i.i_current_price > ( SELECT AVG(j.i_current_price) FROM item j WHERE i.i_category = j.i_category); ``` -------------------------------- ### Start ZooKeeper server Source: https://github.com/trinodb/trino/blob/master/docs/src/main/sphinx/connector/kafka-tutorial.md Initializes the ZooKeeper service using the provided configuration file. ```text $ 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 Output of $manifests Table Source: https://github.com/trinodb/trino/blob/master/docs/src/main/sphinx/connector/iceberg.md Illustrates the structure and content of the data returned by querying the $manifests table. Shows manifest file path, size, and snapshot information. ```text content | path | length | partition_spec_id | added_snapshot_id | added_data_files_count | added_rows_count | existing_data_files_count | existing_rows_count | deleted_data_files_count | deleted_rows_count | partition_summaries ---------+----------------------------------------------------------------------------------------------------------------+-----------------+----------------------+-----------------------+-------------------------+------------------+-----------------------------+---------------------+-----------------------------+--------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------- 0 | hdfs://hadoop-master:9000/user/hive/warehouse/test_table/metadata/faa19903-1455-4bb8-855a-61a1bbafbaa7-m0.avro | 6277 | 0 | 7860805980949777961 | 1 | 100 | 0 | 0 | 0 | 0 | {{contains_null=false, contains_nan= false, lower_bound=1, upper_bound=1},{contains_null=false, contains_nan= false, lower_bound=2021-01-12, upper_bound=2021-01-12}} ``` -------------------------------- ### Partition Start Anchor Source: https://github.com/trinodb/trino/blob/master/docs/src/main/sphinx/sql/match-recognize.md Use the '^' anchor to signify the start of a partition in row pattern matching. ```text ^ ``` -------------------------------- ### Create a PostgreSQL Catalog Source: https://github.com/trinodb/trino/blob/master/docs/src/main/sphinx/sql/create-catalog.md Example of creating a catalog with multiple properties, including environment variable references for sensitive credentials. ```sql CREATE CATALOG example USING postgresql WITH ( "connection-url" = 'jdbc:pg:localhost:5432', "connection-user" = '${ENV:POSTGRES_USER}', "connection-password" = '${ENV:POSTGRES_PASSWORD}', "case-insensitive-name-matching" = 'true' ); ``` -------------------------------- ### Simple CASE Statement Example Source: https://github.com/trinodb/trino/blob/master/docs/src/main/sphinx/udf/sql/case.md Example of a simple CASE statement within a SQL user-defined function. ```sql FUNCTION simple_case(a bigint) RETURNS varchar BEGIN CASE a WHEN 0 THEN RETURN 'zero'; WHEN 1 THEN RETURN 'one'; ELSE RETURN 'more than one or negative'; END CASE; RETURN NULL; END ``` -------------------------------- ### Truncate Table Example Source: https://github.com/trinodb/trino/blob/master/docs/src/main/sphinx/sql/truncate.md Example of how to truncate the 'orders' table. This command deletes all rows from the specified table. ```sql TRUNCATE TABLE orders; ``` -------------------------------- ### Start Prometheus container Source: https://github.com/trinodb/trino/blob/master/docs/src/main/sphinx/admin/openmetrics.md Launches Prometheus with the configuration file mounted from the host. ```shell docker run -d \ --name=prometheus \ --network=platform \ -p 9090:9090 \ --mount type=bind,source=$PWD/prometheus.yml,target=/etc/prometheus/prometheus.yml \ prom/prometheus ``` -------------------------------- ### Install Vale with Homebrew Source: https://github.com/trinodb/trino/blob/master/docs/README.md Installs the Vale command-line tool for editorial style checking on macOS using Homebrew. ```bash brew install vale ``` -------------------------------- ### string.substring(start) Method Source: https://github.com/trinodb/trino/blob/master/docs/src/main/sphinx/language/types.md Returns the part of the string from the 1-based index 'start' to the end. Related: substring() function. ```sql SELECT 'Trino'.substring(2); -- rino ``` -------------------------------- ### Prepare a SELECT statement Source: https://github.com/trinodb/trino/blob/master/docs/src/main/sphinx/sql/describe-output.md Prepare a statement for later use with DESCRIBE OUTPUT. This example prepares a SELECT query on the 'nation' table. ```sql PREPARE my_select1 FROM SELECT * FROM nation; ``` -------------------------------- ### Execute Trino Product Tests Source: https://github.com/trinodb/trino/blob/master/testing/trino-product-tests/README.md Run the product test suite using the PTL launcher after building the project with Maven. ```bash ./mvnw install -DskipTests testing/bin/ptl test run --environment \ [--config ] \ -- ``` -------------------------------- ### Array Type Example Source: https://github.com/trinodb/trino/blob/master/docs/src/main/sphinx/language/types.md Represents an array of a specified component type. Example shows a simple array of integers. ```sql ARRAY[1, 2, 3] ``` -------------------------------- ### Execute a Sample Query Source: https://github.com/trinodb/trino/blob/master/docs/src/main/sphinx/installation/kubernetes.md Execute a sample SQL query against the 'nation' table in the 'tpch.tiny' schema using the Trino CLI. This demonstrates basic query execution and output. ```text trino> select count(*) from tpch.tiny.nation; _col0 ------- 25 (1 row) Query 20181105_001601_00002_e6r6y, FINISHED, 1 node Splits: 21 total, 21 done (100.00%) 0:06 [25 rows, 0B] [4 rows/s, 0B/s] ``` -------------------------------- ### Find pattern position with regexp_position Source: https://github.com/trinodb/trino/blob/master/docs/src/main/sphinx/functions/regexp.md Returns the starting index of a pattern occurrence, with optional start position and occurrence count parameters. ```sql SELECT regexp_position('I have 23 apples, 5 pears and 13 oranges', '\b\d+\b'); -- 8 ``` ```sql SELECT regexp_position('I have 23 apples, 5 pears and 13 oranges', '\b\d+\b', 5); -- 8 SELECT regexp_position('I have 23 apples, 5 pears and 13 oranges', '\b\d+\b', 12); -- 19 ``` ```sql SELECT regexp_position('I have 23 apples, 5 pears and 13 oranges', '\b\d+\b', 12, 1); -- 19 SELECT regexp_position('I have 23 apples, 5 pears and 13 oranges', '\b\d+\b', 12, 2); -- 31 SELECT regexp_position('I have 23 apples, 5 pears and 13 oranges', '\b\d+\b', 12, 3); -- -1 ``` -------------------------------- ### Start Hudi Environment Source: https://github.com/trinodb/trino/blob/master/plugin/trino-hudi/src/test/resources/README.md Initiates the Hudi environment using the PTL tool. ```shell testing/bin/ptl env up --environment singlenode-hudi ``` -------------------------------- ### Check Docker Version Source: https://github.com/trinodb/trino/blob/master/docs/src/main/sphinx/installation/kubernetes.md Verify if Docker is installed on your system. This is a prerequisite for running kind. ```text docker --version ``` -------------------------------- ### Start Jaeger Container Source: https://github.com/trinodb/trino/blob/master/docs/src/main/sphinx/admin/opentelemetry.md Starts the Jaeger all-in-one Docker container in detached mode, enabling OTLP, and mapping necessary ports. ```shell docker run -d \ --name jaeger \ --network=platform \ --network-alias=jaeger \ -e COLLECTOR_OTLP_ENABLED=true \ -p 16686:16686 \ -p 4317:4317 \ jaegertracing/all-in-one:latest ``` -------------------------------- ### Create and Query Daily Visit Summaries with HyperLogLog Source: https://github.com/trinodb/trino/blob/master/docs/src/main/sphinx/functions/hyperloglog.md This example demonstrates creating a table to store daily HyperLogLog sketches of user IDs and then querying for weekly unique users by merging the daily sketches. Ensure the 'visit_date' column is of type date and 'hll' is of type varbinary. ```sql CREATE TABLE visit_summaries ( visit_date date, hll varbinary ); INSERT INTO visit_summaries SELECT visit_date, cast(approx_set(user_id) AS varbinary) FROM user_visits GROUP BY visit_date; SELECT cardinality(merge(cast(hll AS HyperLogLog))) AS weekly_unique_users FROM visit_summaries WHERE visit_date >= current_date - interval '7' day; ``` -------------------------------- ### Example OpenMetrics Data Output Source: https://github.com/trinodb/trino/blob/master/docs/src/main/sphinx/admin/openmetrics.md This is an example of the metrics data format conforming to the OpenMetrics specification. It includes metric types and their values. ```sql # TYPE io_airlift_http_client_type_HttpClient_name_ForDiscoveryClient_CurrentResponseProcessTime_Min gauge io_airlift_http_client_type_HttpClient_name_ForDiscoveryClient_CurrentResponseProcessTime_Min NaN # TYPE io_airlift_http_client_type_HttpClient_name_ForDiscoveryClient_CurrentResponseProcessTime_P25 gauge io_airlift_http_client_type_HttpClient_name_ForDiscoveryClient_CurrentResponseProcessTime_P25 NaN # TYPE io_airlift_http_client_type_HttpClient_name_ForDiscoveryClient_CurrentResponseProcessTime_Total gauge io_airlift_http_client_type_HttpClient_name_ForDiscoveryClient_CurrentResponseProcessTime_Total 0.0 # TYPE io_airlift_http_client_type_HttpClient_name_ForDiscoveryClient_CurrentResponseProcessTime_P90 gauge io_airlift_http_client_type_HttpClient_name_ForDiscoveryClient_CurrentResponseProcessTime_P90 NaN ``` -------------------------------- ### List available environments and configurations Source: https://github.com/trinodb/trino/blob/master/testing/trino-product-tests/README.md Commands to retrieve the list of supported test environments and their specific configurations. ```bash ./mvnw install -DskipTests testing/bin/ptl env list ``` ```bash testing/bin/ptl env list ``` -------------------------------- ### OPA HTTP Client Configuration Example Source: https://github.com/trinodb/trino/blob/master/docs/src/main/sphinx/security/opa-access-control.md Optional HTTP client configurations for the connection from Trino to OPA. Example for configuring an HTTP proxy. ```properties opa.http-client.http-proxy=http://proxy.example.com:8080 ``` -------------------------------- ### Configure Event Listener Properties Source: https://github.com/trinodb/trino/blob/master/docs/src/main/sphinx/develop/event-listener.md Example configuration file for a custom event listener. ```text event-listener.name=custom-event-listener custom-property1=custom-value1 custom-property2=custom-value2 ``` -------------------------------- ### OpenLDAP Group Authorization Example Source: https://github.com/trinodb/trino/blob/master/docs/src/main/sphinx/security/ldap.md An example of the OpenLDAP group authorization pattern, specifying 'inetOrgPerson' as the object class and a concrete group DN. ```text ldap.group-auth-pattern=(&(objectClass=inetOrgPerson)(uid=${USER})(memberof=CN=AuthorizedGroup,OU=Asia,DC=corp,DC=example,DC=com)) ``` -------------------------------- ### Start Fluent Bit Source: https://github.com/trinodb/trino/blob/master/docs/src/main/sphinx/admin/logging.md Command to launch Fluent Bit with the specified configuration file. ```shell fluent-bit -c config.yaml ``` -------------------------------- ### Create and manage password file Source: https://github.com/trinodb/trino/blob/master/docs/src/main/sphinx/security/password-file.md Commands to initialize the database file and add user credentials using htpasswd. ```text touch password.db ``` ```text htpasswd -B -C 10 password.db test ``` -------------------------------- ### Example JDBC Connection URL Source: https://github.com/trinodb/trino/blob/master/docs/src/main/sphinx/client/jdbc.md An example of a JDBC URL to connect to a Trino instance. This URL specifies the host, port, catalog, and schema. ```text jdbc:trino://example.net:8080/hive/sales ``` -------------------------------- ### Build Trino with Maven Source: https://github.com/trinodb/trino/blob/master/README.md Run this command from the project root to clean and install Trino. Tests are skipped by default. ```bash ./mvnw clean install -DskipTests ``` -------------------------------- ### Example Table Creation with Primary Key Source: https://github.com/trinodb/trino/blob/master/docs/src/main/sphinx/connector/mysql.md Demonstrates how to create a table in Trino, specifying a primary key using the 'primary_key' table property. All columns designated as primary keys must be defined as NOT NULL. ```sql CREATE TABLE person ( id INT NOT NULL, name VARCHAR, age INT, birthday DATE ) WITH ( primary_key = ARRAY['id'] ); ``` -------------------------------- ### Descendant Member Accessor Example Source: https://github.com/trinodb/trino/blob/master/docs/src/main/sphinx/functions/json.md Example showing how the descendant member accessor retrieves all values associated with the 'comment' key from nested objects and arrays. ```text ..comment --> ["bar", "baz"], "foo", null ``` -------------------------------- ### Prepare and describe a query with no parameters Source: https://github.com/trinodb/trino/blob/master/docs/src/main/sphinx/sql/describe-input.md Demonstrates preparing a statement without parameters and verifying the empty result set. ```sql PREPARE my_select2 FROM SELECT * FROM nation; ``` ```sql DESCRIBE INPUT my_select2; ``` -------------------------------- ### Connector Query Varchar Table Example (PostgreSQL) Source: https://github.com/trinodb/trino/wiki/Contributor-meetings Demonstrates how to query varchar tables within the PostgreSQL connector. This is a specific example of connector functionality. ```java https://trino.io/docs/current/connector/postgresql.html#query-varchar-table ``` -------------------------------- ### IPAddress Type Examples Source: https://github.com/trinodb/trino/blob/master/docs/src/main/sphinx/language/types.md Represents an IP address, supporting both IPv4 and IPv6. Examples show creating IP addresses using string literals. ```sql IPADDRESS '10.0.0.1' ``` ```sql IPADDRESS '2001:db8::1' ``` -------------------------------- ### Query Plan Output Example Source: https://github.com/trinodb/trino/blob/master/docs/src/main/sphinx/sql/explain-analyze.md This represents the structured output of an EXPLAIN ANALYZE command, showing fragment details and operator metrics. ```text Query Plan ----------------------------------------------------------------------------------------------- Trino version: version Queued: 374.17us, Analysis: 190.96ms, Planning: 179.03ms, Execution: 3.06s Fragment 1 [HASH] CPU: 22.58ms, Scheduled: 96.72ms, Blocked 46.21s (Input: 23.06s, Output: 0.00ns), Input: 1000 rows (37.11kB); per task: avg.: 1000.00 std.dev.: 0.00, Output: 1000 rows (28.32kB) Output layout: [clerk, count] Output partitioning: SINGLE [] Project[] │ Layout: [clerk:varchar(15), count:bigint] │ Estimates: {rows: ? (?), cpu: ?, memory: 0B, network: 0B} │ CPU: 8.00ms (3.51%), Scheduled: 63.00ms (15.11%), Blocked: 0.00ns (0.00%), Output: 1000 rows (28.32kB) │ Input avg.: 15.63 rows, Input std.dev.: 24.36% └─ Aggregate[type = FINAL, keys = [clerk], hash = [$hashvalue]] │ Layout: [clerk:varchar(15), $hashvalue:bigint, count:bigint] │ Estimates: {rows: ? (?), cpu: ?, memory: ?, network: 0B} │ CPU: 8.00ms (3.51%), Scheduled: 22.00ms (5.28%), Blocked: 0.00ns (0.00%), Output: 1000 rows (37.11kB) │ Input avg.: 15.63 rows, Input std.dev.: 24.36% │ count := count("count_0") └─ LocalExchange[partitioning = HASH, hashColumn = [$hashvalue], arguments = ["clerk"]] │ Layout: [clerk:varchar(15), count_0:bigint, $hashvalue:bigint] │ Estimates: {rows: ? (?), cpu: ?, memory: 0B, network: 0B} │ CPU: 2.00ms (0.88%), Scheduled: 4.00ms (0.96%), Blocked: 23.15s (50.10%), Output: 1000 rows (37.11kB) │ Input avg.: 15.63 rows, Input std.dev.: 793.73% └─ RemoteSource[sourceFragmentIds = [2]] Layout: [clerk:varchar(15), count_0:bigint, $hashvalue_1:bigint] CPU: 0.00ns (0.00%), Scheduled: 0.00ns (0.00%), Blocked: 23.06s (49.90%), Output: 1000 rows (37.11kB) Input avg.: 15.63 rows, Input std.dev.: 793.73% Fragment 2 [SOURCE] CPU: 210.60ms, Scheduled: 327.92ms, Blocked 0.00ns (Input: 0.00ns, Output: 0.00ns), Input: 1500000 rows (18.17MB); per task: avg.: 1500000.00 std.dev.: 0.00, Output: 1000 rows (37.11kB) Output layout: [clerk, count_0, $hashvalue_2] Output partitioning: HASH [clerk][$hashvalue_2] Aggregate[type = PARTIAL, keys = [clerk], hash = [$hashvalue_2]] │ Layout: [clerk:varchar(15), $hashvalue_2:bigint, count_0:bigint] │ CPU: 30.00ms (13.16%), Scheduled: 30.00ms (7.19%), Blocked: 0.00ns (0.00%), Output: 1000 rows (37.11kB) │ Input avg.: 818058.00 rows, Input std.dev.: 0.00% │ count_0 := count(*) └─ ScanFilterProject[table = hive:sf1:orders, filterPredicate = ("orderdate" > DATE '1995-01-01')] Layout: [clerk:varchar(15), $hashvalue_2:bigint] Estimates: {rows: 1500000 (41.48MB), cpu: 35.76M, memory: 0B, network: 0B}/{rows: 816424 (22.58MB), cpu: 35.76M, memory: 0B, network: 0B}/{rows: 816424 (22.58MB), cpu: 22.58M, memory: 0B, network: 0B} CPU: 180.00ms (78.95%), Scheduled: 298.00ms (71.46%), Blocked: 0.00ns (0.00%), Output: 818058 rows (12.98MB) Input avg.: 1500000.00 rows, Input std.dev.: 0.00% $hashvalue_2 := combine_hash(bigint '0', COALESCE("$operator$hash_code"("clerk"), 0)) clerk := clerk:varchar(15):REGULAR orderdate := orderdate:date:REGULAR Input: 1500000 rows (18.17MB), Filtered: 45.46%, Physical Input: 4.51MB ```