{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":["admonition"]},"redocly_category":"Products","product_name":"Data Workbench","type":"markdown"},"seo":{"title":"Trino Quickstart","description":"Treasure Data Product Documentation · Collect and Unify · Segment and Activate · Experiment and Analyze · Decisioning Automate with AI Scale and Trust.","siteUrl":"https://docs.treasuredata.com","lang":"en-US","llmstxt":{"hide":false,"sections":[{"title":"Table of contents","includeFiles":["**/*"],"excludeFiles":[]}],"excludeFiles":[]}},"dynamicMarkdocComponents":[],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"trino-quickstart","__idx":0},"children":["Trino Quickstart"]},{"$$mdtype":"Tag","name":"Admonition","attributes":{"type":"warning","name":"Info"},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Prior to its rebranding in 2021, the Trino query engine was known as PrestoSQL or more simply Presto. Treasure Data supported several earlier versions of Presto. Newer versions of Presto are now supported under the Trino branding, and support for ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/products/customer-data-platform/data-workbench/queries/trino/trino-423"},"children":["Trino 423"]}," has now been introduced. For the immediate future, you will see both Presto and Trino used in Treasure Data documentation. New functionality or new features will be identified as being Trino; however, documentation for existing functions and features that are common to both Presto and Trino will continue to be identified as Presto."]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/trinodb/trino"},"children":["Trino"]}," is an open-source,"," ","distributed SQL query engine. Trino can query data where it is stored,"," ","without needing to move data into a separate analytics system. Treasure"," ","Data has customized Trino to talk directly with our distributed"," ","columnar storage layer."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"accessing-trino","__idx":1},"children":["Accessing Trino"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["You can access Trino using the following:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Treasure Console"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Trino JDBC/ODBC Driver"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["TD Toolbelt"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["REST API"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Data Tank with Trino"]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"treasure-console","__idx":2},"children":["Treasure Console"]},{"$$mdtype":"Tag","name":"ol","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Open the Treasure Console"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Open the ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Data Workbench"]}]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Select ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Queries"]},{"$$mdtype":"Tag","name":"br","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"img","attributes":{"src":"/assets/345090.de1e51b9284b079634025bc992c1cb036c6294932e248c711fa72f0469f6d2dd.89112c51.png","alt":"image","title":"#box-shadow=0px 0px 2px 1px blue"},"children":[]}]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Click ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["New Query"]}," button",{"$$mdtype":"Tag","name":"br","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"img","attributes":{"src":"/assets/345092.a637e42e590f7a9c6f56508896620c3f65844fcb5ba968466d5c5821bcd134b0.89112c51.png","alt":"image","title":"#box-shadow=0px 0px 2px 1px blue"},"children":[]}]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Select the query type of ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Trino"]},", write a query on the editor and click \"Run\" button"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["After you run your query, you can check the query processing log",{"$$mdtype":"Tag","name":"br","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"img","attributes":{"src":"/assets/345091.8e1477613a2b2185a7fe38eec14a9699bbeec53406e77ec95716a49c50c98757.0053d791.png","alt":"image","title":"#box-shadow=0px 0px 2px 1px blue"},"children":[]}]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"trino-gateway","__idx":3},"children":["Trino Gateway"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The US Trino gateway resides at api-presto.treasuredata.com/. Additional endpoints can be found ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/apis/endpoints/endpoints"},"children":["here"]},". You can use the TD toolbelt and drivers to connect to Treasure Data and issue queries."]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"#about-the-jdbc-driver-for-trino"},"children":["JDBC Driver for Trino"]}," - can be used by a Java application to connect to, and issue queries to, the Trino query engine."]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"#odbc-driver-for-trino"},"children":["ODBC Driver for Trino"]}," - can be used by Windows applications to connect to, and issue queries to, the Trino query engine."]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"about-the-jdbc-driver-for-trino","__idx":4},"children":["About the JDBC Driver for Trino"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The Trino JDBC connection has several limitations:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["setAutoCommit(false) throws an exception because transactions are not supported."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["trino-jdbc queries share the same Trino resources you have available for any other ad hoc or scheduled queries that you submit from the Treasure Console or through the REST API."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["trino-jdbc queries are shown in your account job log, with the exception of the following standard entries:",{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Query result table"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Query plan"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Progress log"]}]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["The query result is converted into JSON before being submitted back to separate tools for display. As such, very large result tables may take some time before being displayed. If you have latency problems, contact Support."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Certain BI tools issue “information_schema” requests that cause failed queries in our system. This may be an issue in your tool during first use."]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["If you see any unexpected errors/bugs/logs that occur during beta use, contact Support."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Our aim is to keep this API up as much as possible. Specifically, we expect to achieve a downtime of less than 1 hour total per month."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Setting up the JDBC Driver for Trino"]}]},{"$$mdtype":"Tag","name":"ol","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Download the ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://repo1.maven.org/maven2/io/trino/trino-jdbc/423/trino-jdbc-423.jar"},"children":["Trino jdbc driver"]},"."]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["For using secure HTTPS (port 443) connection you need to use Trino 0.148 or later."]}]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Use the following parameters to connect prestobase on development server:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Driver name: io.trino.jdbc.TrinoDriver (if you use TrinoSQL Driver, you may use io.prestosql.jdbc.PrestoDriver)"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["user: (Your Treasure API key)"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["password: (dummy string. This value will be ignored)",{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["After Trino-jdbc 0.180, because of a ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/prestodb/presto/issues/8566"},"children":["bug"]},", a dummy string needs to be set to the password."]}]}]}]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Connection URL examples"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The connection URL needs to have the following format:"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["jdbc:trino://api-presto.treasuredata.com:443/td/(database name)?SSL=true"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["or"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["jdbc:presto://api-presto.treasuredata.com:443/td/(database name)?SSL=true"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"jdbc:trino://api-presto.treasuredata.com:443/td?SSL=true\n\nor\n\njdbc:trino://api-presto.treasuredata.com:443/td/sample_datasets?SSL=true\n\n"},"children":[]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"\njdbc:presto://api-presto.treasuredata.com:443/td?SSL=true\n\nor\n\njdbc:presto://api-presto.treasuredata.com:443/td/sample_datasets?SSL=true\n"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"em","attributes":{},"children":["Example Code"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"javac Sample.java\njava -cp .:trino-jdbc-0.359.jar Sample (your TD API key)\n","lang":"bash"},"children":[]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"time=1412351990, method=GET, path=/category/office\ntime=1412351976, method=GET, path=/item/software/2265\ntime=1412351961, method=GET, path=/category/toys\ntime=1412351947, method=GET, path=/item/electronics/3305\ntime=1412351932, method=GET, path=/category/software\n"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"em","attributes":{},"children":["Sample.java File"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"java","header":{"controls":{"copy":{}}},"source":"import java.sql.*;\n\nclass Sample {\n  public static void main(String[] args) {\n    if(args.length != 1) {\n      System.err.println(\"Provide your TD API key as an argument\");\n      return;\n    }\n\n    String apikey = args[0];\n    try {\n      Connection conn = DriverManager.getConnection(\"jdbc:trino://api-presto.treasuredata.com:443/td/sample_datasets?SSL=true\", apikey, \"dummy_password\");\n      Statement stmt = conn.createStatement();\n      try {\n        ResultSet rs = stmt.executeQuery(\"SELECT time, method, path from www_access limit 5\");\n        while(rs.next()) {\n            long time = rs.getLong(1);\n            String method = rs.getString(2);\n            String path = rs.getString(3);\n            System.out.println(String.format(\"time=%s, method=%s, path=%s\", time, method, path));\n        }\n      }\n      finally {\n        stmt.close();\n        conn.close();\n      }\n    }\n    catch (Exception e) {\n      e.printStackTrace();\n    }\n  }\n}\n","lang":"java"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"odbc-driver-for-trino","__idx":5},"children":["ODBC Driver for Trino"]},{"$$mdtype":"Tag","name":"Admonition","attributes":{"type":"danger"},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The Presto ODBC driver will be deprecated in June 2025. There are no plans to provide updates to the ODBC driver in the future; consider using the OSS ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://repo1.maven.org/maven2/io/trino/trino-jdbc/"},"children":["Trino JDBC Drive"]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Treasure Data provides a Trino API that can integrate directly with our Trino-specific ODBC driver. The installer for the driver is currently available for Windows 64-bit platform only. Downloads are available from your account or support representative."]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Windows Treasure Data Trino ODBC Driver installer"," ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://treasure-data.app.box.com/s/7i1dfqvxsczarsv210gglwvgwtb87i1c"},"children":["TreasureDataPrestoODBC.msi"]}]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Tableau Datasource Customization File (.tdc) for Tableau users."," ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://treasure-data.box.com/s/lmoidymjdd28ijfiagjp4qwrilyh0un6"},"children":["Treasure Data Trino ODBC Driver.tdc"]}]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Copy this file to My Documents\\My Tableau Repositories\\Data Sources folder. (This file controls Tableau to use Trino compatible SQL queries.)"]}]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Windows System Requirements"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["One of the following operating systems:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Windows Vista, 7, 8, or 10"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Windows Server 2008 or later"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://www.microsoft.com/en-ca/download/details.aspx?id=40784"},"children":["Visual C++ Redistributable Packages for Visual Studio 2013"]}," installed."]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Migrate from Treasure Data ODBC Driver for 32bit"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Treasure Data ODBC Driver for 32bit is no longer supported. Replace it with Trino ODBC Driver according to the following instructions. The old driver is no longer supported."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Install the Driver on Windows (64-bit)"]}]},{"$$mdtype":"Tag","name":"ol","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Download the ODBC driver installer ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://treasure-data.app.box.com/s/jka8w6kkdpr2kqmzomwvjxpw2n8ocrev"},"children":["TreasureDataTrinoODBC.msi"]},"."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Double-click on the installer package and follow the instructions."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Open the Start menu (or press the Windows key) and search/select ‘ODBC Data Source Administrator (64-bit)’."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Select Treasure Data Trino ODBC DSN, and select ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Configure"]},"."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Enter your Master Treasure API key into the User field."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Type the following values:",{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Authentication Type: No Authentication"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["User: YOUR MASTER API KEY"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Host: https://api-presto.treasuredata.com"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Port: 443"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Catalog: td"]}]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"img","attributes":{"src":"/assets/presto-odbc1.a114edfb7b7abe7432d16c666e4f87ea54abce3a10645d828d3a5fc585e77c66.0053d791.png","alt":"image","title":"#width=500px;#box-shadow=0px 0px 2px 1px blue"},"children":[]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"img","attributes":{"src":"/assets/presto-odbc2.ca0d9e6ca052229eae40d3b62821101e8dd629b5b7f82012f1bd405d1da46e1a.0053d791.png","alt":"image","title":"#width=700px;#box-shadow=0px 0px 2px 1px blue"},"children":[]}]},{"$$mdtype":"Tag","name":"ol","attributes":{"start":7},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Select ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Test"]},"."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["If successful, press ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["OK"]},"."]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Configure the Proxy Server"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["If you are connecting to a data source through a proxy server, you must provide connection information for the proxy server."]},{"$$mdtype":"Tag","name":"ol","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Open the ODBC Data Source Administrator where you created the DSN. Select the DSN, select ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Configure"]},", and then select ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Proxy Options"]},"."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Check the ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Use Proxy Server"]}," box."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["In the ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Proxy Host"]}," field, enter the hostname or IP address of the proxy server."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["In the ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Proxy Port"]}," field, enter the TCP port number that the proxy server uses to listen for client connections."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["In the ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Proxy Username"]}," field, enter your user name for accessing the proxy server."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["In the ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Proxy Password"]}," field, enter the password of the user name."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["(Optional) To save the proxy server in the Windows registry, select ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Save Password (Encrypted)"]},"."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Click ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["OK"]},"."]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"td-toolbelt","__idx":6},"children":["TD Toolbelt"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["You can use the Toolbelt command-line (CLI) client to submit Trino queries."]},{"$$mdtype":"Tag","name":"ol","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Ensure that ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/tools/cli-and-sdks/quickstart"},"children":["TD Toolbelt"]}," is installed."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Execute ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["td query"]}," command like the following:"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"td query -w -T presto -d testdb \"SELECT code, COUNT(1) FROM www_access GROUP BY code\"\n"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"rest-api","__idx":7},"children":["REST API"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["You can use ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/apis/td_api_v3-public/jobs/createjob"},"children":["POST /v3/job/issue/presto/:database"]}," endpoint to submit Trino queries."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"data-tank-with-trino","__idx":8},"children":["Data Tank with Trino"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Learn about the ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/products/customer-data-platform/data-workbench/queries/trino/data_tanks_using_presto#how-does-trino-query-processing-flow"},"children":["Trino query processing flow"]}," that"," ","joins data from a TD table with data from a Data Tank table."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"trino-query-runtime-limits-and-query-hint-override","__idx":9},"children":["Trino Query Runtime Limits and Query Hint Override"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["By default, the Trino service limits query execution time to 6 hours."," ","You can manage the Trino query execution time in several ways."," ","You might want to limit some or all Trino queries to run for a shorter"," ","period. For example:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["You can limit execution time for ad hoc queries by default, to avoid"," ","unexpectedly high Trino costs."]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["You can push users to choose Hive over Trino for large and"," ","long-running data pipeline jobs."]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"policies-to-limit-query-execution-time","__idx":10},"children":["Policies to Limit Query Execution Time"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Contact Support to request custom limits on the following types of"," ","queries:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Ad hoc queries from the Console, and queries submitted through ODBC"," ","and JDBC"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Queries that run as scheduled queries or as steps in workflows"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Queries explicitly assigned to any named resource pool"]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The limits apply to queries created by any user."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"limiting-execution-time-of-a-single-query-with-query-hints","__idx":11},"children":["Limiting Execution Time of a Single Query with Query Hints"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["If you want to override any other limits for a single query, you can"," ","apply the following query hint at the beginning of the query:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"-- SET SESSION query_max_execution_time = '6h'\nSELECT\n  COUNT(*)\nFROM\n  ALL_EVENTS\n;\n"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["If limits are set in your account, and you write a query with a hint,"," ","then the smallest limit between account, resource-group, query-hint, and"," ","global is used."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Supported time measures are"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["h (hours)"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["m (minutes)"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["s (seconds)"]}]},{"$$mdtype":"Tag","name":"Admonition","attributes":{"type":"info","name":"info"},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["All Trino queries are limited to 6 hours runtime, regardless of any account-level policy or query hint."]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["If the limit specified in the query hint is longer than the configured"," ","limit, then the shorter configured limit still applies. For example, if"," ","a 1-hour limit is configured for ad hoc queries, then you can use the"," ","magic comment to limit a query to 5 minutes (5m) but not to increase the"," ","limit to 2 hours (2h)."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"scheduling-trino-queries","__idx":12},"children":["Scheduling Trino Queries"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["You might encounter queries that take a very long time to finish. For"," ","example, suppose you query the IP addresses of your website visitors"," ","which you want to convert into countries and then make a daily summary"," ","of all visitors by each country. The query examines the data of IP"," ","addresses from the first visitor to the most recent. This query is"," ","processed over and over again for each query, resulting in a query that"," ","takes over an hour to complete."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"stream-data-processing","__idx":13},"children":["Stream Data Processing"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Stream data processing uses intermediate tables where only the ",{"$$mdtype":"Tag","name":"em","attributes":{},"children":["new"]}," ","data (data that arrived since the last query) is processed and appended"," ","to the rest of the processed data, rather than processing the entire"," ","data every time."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["For example, you would create an intermediate table by processing all the data you have up to a certain point in time. Then you would schedule a query that processes the new data that arrived since the last query and append the data to the intermediate table. And, finally, you would query the intermediate table for the aggregated data."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"creating-intermediate-tables","__idx":14},"children":["Creating Intermediate Tables"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The following example uses these elements to create the table:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Sample database: sample_db"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Intermediate table: visitor_country"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Raw data table: visitor_raw"]}]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"sql","header":{"controls":{"copy":{}}},"source":"CREATE TABLE visitor_country AS SELECT\n  TD_DATE_TRUNK('day', time, 'PST') AS time,\n  userid,\n  TD_IP_TO_COUNTRY_CODE(ip) country\nFROM visitor_raw\nWHERE TD_TIME_RANGE(time, null, '2017-07-01', 'PST')\n","lang":"sql"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"scheduling-and-appending-to-the-intermediate-tables","__idx":15},"children":["Scheduling and Appending to the Intermediate Tables"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"sql","header":{"controls":{"copy":{}}},"source":"INSERT INTO visitor_country\nSELECT\n  TD_DATE_TRUNK('day', time, 'PST') AS time,\n  userid,\n  TD_IP_TO_COUNTRY_CODE(ip) country\nFROM visitor_raw\nWHERE TD_TIME_RANGE(time, TD_TIME_ADD(TD_SCHEDULED_TIME(), ‘-1d’), TD_SCHEDULED_TIME(), ‘PST’);\n","lang":"sql"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"aggregating-the-intermediate-tables","__idx":16},"children":["Aggregating the Intermediate Tables"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"sql","header":{"controls":{"copy":{}}},"source":"SELECT country, approx_distinct(userid) num_users\nFROM vistitor_country\nGROUP BY 1\n","lang":"sql"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"further-reading","__idx":17},"children":["Further Reading"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Review one or more of the following topics to learn more about using the"," ","Trino Query Engine:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/products/customer-data-platform/data-workbench/queries/trino/writing_trino_queries"},"children":["Writing Trino Queries"]}," - provides examples of different types of Trino queries."]}]}]},"headings":[{"value":"Trino Quickstart","id":"trino-quickstart","depth":1},{"value":"Accessing Trino","id":"accessing-trino","depth":2},{"value":"Treasure Console","id":"treasure-console","depth":3},{"value":"Trino Gateway","id":"trino-gateway","depth":3},{"value":"About the JDBC Driver for Trino","id":"about-the-jdbc-driver-for-trino","depth":3},{"value":"ODBC Driver for Trino","id":"odbc-driver-for-trino","depth":3},{"value":"TD Toolbelt","id":"td-toolbelt","depth":3},{"value":"REST API","id":"rest-api","depth":3},{"value":"Data Tank with Trino","id":"data-tank-with-trino","depth":3},{"value":"Trino Query Runtime Limits and Query Hint Override","id":"trino-query-runtime-limits-and-query-hint-override","depth":2},{"value":"Policies to Limit Query Execution Time","id":"policies-to-limit-query-execution-time","depth":3},{"value":"Limiting Execution Time of a Single Query with Query Hints","id":"limiting-execution-time-of-a-single-query-with-query-hints","depth":3},{"value":"Scheduling Trino Queries","id":"scheduling-trino-queries","depth":2},{"value":"Stream Data Processing","id":"stream-data-processing","depth":2},{"value":"Creating Intermediate Tables","id":"creating-intermediate-tables","depth":3},{"value":"Scheduling and Appending to the Intermediate Tables","id":"scheduling-and-appending-to-the-intermediate-tables","depth":3},{"value":"Aggregating the Intermediate Tables","id":"aggregating-the-intermediate-tables","depth":3},{"value":"Further Reading","id":"further-reading","depth":2}],"frontmatter":{"seo":{"title":"Trino Quickstart"}},"lastModified":"2026-06-01T09:09:59.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/products/customer-data-platform/data-workbench/queries/trino/quickstart","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}