{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":["platform-badges","admonition"]},"type":"markdown"},"seo":{"title":"Treasure AI Studio - Query Execution (Trino)","description":"Run Trino SQL queries through natural language. The AI writes, executes, and renders results as structured tables.","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":"query-execution-trino","__idx":0},"children":["Query Execution (Trino)"]},{"$$mdtype":"Tag","name":"PlatformBadges","attributes":{"platforms":["Web","Desktop","Mobile"]},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Ask a data question in plain English and watch Studio translate it into optimized Trino SQL, execute it against your account, and render the results — all within the chat stream. Full SQL visibility means you can verify every query before acting on the results."]},{"$$mdtype":"Tag","name":"Admonition","attributes":{"type":"info","name":"Note"},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The AI uses the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["tdx query"]}," command inside the sandbox execution environment to run Trino queries. Every generated SQL statement is visible in the tool call expansion, so you can review, copy, and re-run it independently."]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"objective","__idx":1},"children":["Objective"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Execute Trino queries against your Treasure AI account through natural-language requests and receive structured, readable results inline in the conversation."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"prerequisites","__idx":2},"children":["Prerequisites"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Signed in to Treasure AI Studio (",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/products/ai-studio/getting-started"},"children":["Getting Started"]},")"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["At least one database accessible in your Treasure AI account"]}]},{"$$mdtype":"Tag","name":"hr","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"querying-through-the-ai","__idx":3},"children":["Querying Through the AI"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The simplest way to query data is to describe what you want in plain language:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["\"Show me the top 10 customers by revenue in the last 30 days\""]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["\"How many rows are in the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["pageviews"]}," table?\""]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["\"What columns does ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["mydb.users"]}," have?\""]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The AI translates your request into a Trino SQL query, executes it using ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["tdx query"]},", and presents the results in a formatted table — all within the chat stream."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"what-happens-under-the-hood","__idx":4},"children":["What Happens Under the Hood"]},{"$$mdtype":"Tag","name":"ol","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["You describe your query"]}," in natural language"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["The AI writes SQL"]}," and executes it via the Bash tool: ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["tdx query \"SELECT ...\""]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["The tool call appears"]}," in the chat showing the command being executed"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Query results render"]}," automatically as a structured table (see ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/products/ai-studio/query/query-results"},"children":["Query Result Tables"]},")"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["The AI interprets"]}," the results and continues the conversation"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["You can watch each step happen in real time. The tool call indicator shows the running command, and the result table auto-expands when results arrive."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"requesting-specific-commands","__idx":5},"children":["Requesting Specific Commands"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["For precise control over query syntax and execution, ask the AI to run the exact command you want:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"You: Run tdx query \"SELECT count(*) AS total_users FROM mydb.users\"\n"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Or ask it to use ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["tdx describe"]}," and ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["tdx show"]}," for quick schema exploration:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"You: Describe the mydb.users table\nYou: Show me a preview of mydb.users\n"},"children":[]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Command"},"children":["Command"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Purpose"},"children":["Purpose"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Output"},"children":["Output"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["tdx query \"<sql>\""]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Execute arbitrary Trino SQL"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Query result table"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["tdx describe <db.table>"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Show table schema (column names and types)"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Schema table"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["tdx show <db.table>"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Preview table data (SELECT * with default limit)"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Data table"]}]}]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["See ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/products/ai-studio/query/tdx-commands"},"children":["TDX Commands"]}," for the full command reference."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"query-lifecycle-in-the-chat","__idx":6},"children":["Query Lifecycle in the Chat"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["When a query executes, you see a ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["tool call indicator"]}," in the chat stream:"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"while-running","__idx":7},"children":["While Running"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["A ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["spinning loader"]}," icon indicates the query is in progress"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["The ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["command description"]}," appears with the full command preview below in monospace"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["You can see exactly what SQL is being executed"]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"on-completion","__idx":8},"children":["On Completion"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["A ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["green checkmark"]}," replaces the spinner"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["The tool call row becomes ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["expandable"]}," — click to see the full command and raw output"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["A ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["query result table"]}," renders automatically below the tool call, showing structured results with column headers, types, and formatted data"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Execution stats"]}," appear below the table (see ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/products/ai-studio/query/query-results"},"children":["Query Result Tables"]}," for details)"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Duration badge"]}," shows execution time if 1 second or longer (e.g., \"3.2s\")"]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"on-error","__idx":9},"children":["On Error"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["A ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["red X"]}," icon indicates the query failed"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["A ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["\"Query failed\""]}," error card displays with:",{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["The SQL that was executed (in monospace)"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["The error message from the query engine"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["The ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Job ID"]}," for troubleshooting"]}]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["If the tool exited with a non-zero status, an ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Exit code badge"]}," (e.g., \"Exit 1\") appears"]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"stopping-a-query","__idx":10},"children":["Stopping a Query"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["If a query is running as part of the AI's response, click the ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Stop"]}," button (square icon) in the chat input area to interrupt the AI's execution stream."]},{"$$mdtype":"Tag","name":"Admonition","attributes":{"type":"info","name":"Note"},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Stopping the response terminates the AI's execution stream. The query itself may continue running on the Trino engine. Use the Treasure AI console to cancel long-running queries if needed."]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"query-detection","__idx":11},"children":["Query Detection"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Studio automatically detects query results from Bash tool calls. The UI recognizes commands containing:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["tdx query"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["tdx describe"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["tdx show"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["trino"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["presto"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["psql"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["mysql"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["sqlite3"]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["When detected, the raw output is parsed into a structured table rather than displayed as plain text. Two output formats are recognized:"]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Format"},"children":["Format"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Description"},"children":["Description"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["JSON array"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["[{\"col1\": val1, ...}, ...]"]}," — produced by ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["--json"]}," flag"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Box-drawing table"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Unicode table format with ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["┌─│├┤┘"]}," characters — the default ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["tdx query"]}," output"]}]}]}]}]},{"$$mdtype":"Tag","name":"Admonition","attributes":{"type":"info","name":"Technical Note"},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Query detection happens client-side via the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["detectQueryResult()"]}," function, which inspects the Bash command string and output format. If a Bash tool call matches a query command pattern and its output contains valid JSON arrays or box-drawing table characters, the output renders as a ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["QueryResultTable"]}," component instead of plain text. The table auto-expands when results are detected during streaming."]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"using-skills-for-query-optimization","__idx":12},"children":["Using Skills for Query Optimization"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["For complex queries, activate the built-in SQL skills in your project settings to reduce latency and improve efficiency:"]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Skill"},"children":["Skill"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"What It Does"},"children":["What It Does"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["sql-skills:trino"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Write Trino SQL with Treasure AI best practices"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["sql-skills:hive"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Write Hive SQL for heavy workloads"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["sql-skills:time-filtering"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Apply ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["td_interval"]}," and partition pruning for time-based queries"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["sql-skills:trino-optimizer"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Analyze and optimize slow Trino queries"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["sql-skills:trino-to-hive-migration"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Convert memory-heavy Trino queries to Hive"]}]}]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Example: With the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["sql-skills:trino-optimizer"]}," skill active, ask the AI to analyze your query for latency bottlenecks. It suggests partition pruning, predicate pushdown, and other optimizations."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["See ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/products/ai-studio/skills/skills"},"children":["Skills & Marketplace"]}," for the full skills catalog."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"best-practices","__idx":13},"children":["Best Practices"]},{"$$mdtype":"Tag","name":"ol","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Start with natural language."]}," Let the AI write the first draft of your query. Review the SQL in the tool call before interpreting results."]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Use ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["tdx describe"]}," before querying."]}," Understanding the schema (column names, types) helps both you and the AI write accurate queries."]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Set a database context."]}," Ask the AI to run ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["tdx use database mydb"]}," at the start of a session to avoid typing fully qualified table names in every query."]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Review generated SQL."]}," The AI writes SQL based on your description and the schema it discovers. Always review the query in the tool call expansion before acting on the results."]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Use output format flags for large results."]}," When you need to process large result sets, ask the AI to use ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["--json"]}," for structured output or ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["--output results.csv"]}," to save results to a file."]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"verification","__idx":14},"children":["Verification"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"input","attributes":{"checked":false,"type":"checkbox","readOnly":true},"children":[]}," Ask \"How many rows are in [your_database].[your_table]?\" and see a tool call execute ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["tdx query"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"input","attributes":{"checked":false,"type":"checkbox","readOnly":true},"children":[]}," See the result rendered as a structured table with column headers and types"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"input","attributes":{"checked":false,"type":"checkbox","readOnly":true},"children":[]}," Expand the tool call to see the full SQL and raw output"]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"troubleshooting","__idx":15},"children":["Troubleshooting"]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Issue"},"children":["Issue"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Solution"},"children":["Solution"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Query takes too long"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Use the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["sql-skills:trino-optimizer"]}," skill to analyze for latency issues. Common causes: full table scans (add partition pruning), excessive JOINs, or missing WHERE clauses on time columns"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Query fails with \"access denied\""]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Verify your Treasure AI account has access to the database and table. Ask the AI to run ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["tdx databases"]}," to check available databases"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["AI writes incorrect SQL"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Activate the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["sql-skills:trino"]}," skill before your query request. This gives the AI Treasure AI-specific SQL patterns and functions"]}]}]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"next-steps","__idx":16},"children":["Next Steps"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/products/ai-studio/query/query-results"},"children":["Query Result Tables"]}," — Formatting, column types, and stats"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/products/ai-studio/query/tdx-commands"},"children":["TDX Commands"]}," — Full CLI command reference"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/products/ai-studio/skills/skills"},"children":["Skills & Marketplace"]}," — SQL skills for optimization and best practices"]}]}]},"headings":[{"value":"Query Execution (Trino)","id":"query-execution-trino","depth":1},{"value":"Objective","id":"objective","depth":2},{"value":"Prerequisites","id":"prerequisites","depth":2},{"value":"Querying Through the AI","id":"querying-through-the-ai","depth":2},{"value":"What Happens Under the Hood","id":"what-happens-under-the-hood","depth":3},{"value":"Requesting Specific Commands","id":"requesting-specific-commands","depth":2},{"value":"Query Lifecycle in the Chat","id":"query-lifecycle-in-the-chat","depth":2},{"value":"While Running","id":"while-running","depth":3},{"value":"On Completion","id":"on-completion","depth":3},{"value":"On Error","id":"on-error","depth":3},{"value":"Stopping a Query","id":"stopping-a-query","depth":2},{"value":"Query Detection","id":"query-detection","depth":2},{"value":"Using Skills for Query Optimization","id":"using-skills-for-query-optimization","depth":2},{"value":"Best Practices","id":"best-practices","depth":2},{"value":"Verification","id":"verification","depth":2},{"value":"Troubleshooting","id":"troubleshooting","depth":2},{"value":"Next Steps","id":"next-steps","depth":2}],"frontmatter":{"seo":{"title":"Treasure AI Studio - Query Execution (Trino)","description":"Run Trino SQL queries through natural language. The AI writes, executes, and renders results as structured tables."},"platforms":["Web","Desktop","Mobile"]},"lastModified":"2026-04-23T08:10:59.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/products/ai-studio/query/query-execution","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}