{"title":"SQL Explorer","description":"Explore Altertable data with SQL, browse catalogs, run DuckDB-powered queries, and inspect results from your lakehouse.","order":50,"askSuggestions":["How do I save a query as a reusable visualization?","Can an agent help me write a query in SQL Explorer?"],"navigation":true,"body":{"code":"var Component=(()=>{var p=Object.create;var a=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var w=Object.getOwnPropertyNames;var x=Object.getPrototypeOf,g=Object.prototype.hasOwnProperty;var f=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),y=(t,e)=>{for(var r in e)a(t,r,{get:e[r],enumerable:!0})},i=(t,e,r,s)=>{if(e&&typeof e==\"object\"||typeof e==\"function\")for(let o of w(e))!g.call(t,o)&&o!==r&&a(t,o,{get:()=>e[o],enumerable:!(s=m(e,o))||s.enumerable});return t};var k=(t,e,r)=>(r=t!=null?p(x(t)):{},i(e||!t||!t.__esModule?a(r,\"default\",{value:t,enumerable:!0}):r,t)),S=t=>i(a({},\"__esModule\",{value:!0}),t);var l=f((Q,c)=>{c.exports=_jsx_runtime});var L={};y(L,{default:()=>u,frontmatter:()=>q});var n=k(l()),q={title:\"SQL Explorer\",description:\"Explore Altertable data with SQL, browse catalogs, run DuckDB-powered queries, and inspect results from your lakehouse.\",order:50,askSuggestions:[\"How do I save a query as a reusable visualization?\",\"Can an agent help me write a query in SQL Explorer?\"]};function d(t){let e={a:\"a\",code:\"code\",h1:\"h1\",h2:\"h2\",li:\"li\",p:\"p\",pre:\"pre\",strong:\"strong\",ul:\"ul\",...t.components},{DocsPreviewDocument:r,DocsPreviewSection:s}=e;return r||h(\"DocsPreviewDocument\",!0),s||h(\"DocsPreviewSection\",!0),(0,n.jsxs)(r,{anchors:\"query-with-sql-explorer worksheets-and-execution-details example when-to-use-it learn-more\",children:[(0,n.jsxs)(s,{sectionId:\"query-with-sql-explorer\",anchors:\"\",ancestors:\"\",index:\"0\",children:[(0,n.jsx)(e.h1,{id:\"query-with-sql-explorer\",children:\"Query with SQL Explorer\"}),`\n`,(0,n.jsx)(e.p,{children:\"SQL Explorer is the in-app workspace for writing and running ad-hoc SQL against Altertable. Use it when you want to inspect tables, test joins, debug a query, or turn an exploration into a saved analysis.\"}),`\n`,(0,n.jsxs)(e.p,{children:[\"Queries use the same \",(0,n.jsx)(e.a,{href:\"/docs/lakehouse/sql-engine\",children:\"DuckDB SQL dialect\"}),\" as the rest of the lakehouse. You can reference Altertable catalogs and external catalogs in one statement.\"]}),`\n`,(0,n.jsxs)(e.p,{children:[\"Select \",(0,n.jsx)(e.strong,{children:\"Ask Agent\"}),\" in SQL Explorer when you want help drafting or refining a query without leaving the workspace. Review the generated SQL before running it, especially when it writes data.\"]}),`\n`]}),(0,n.jsxs)(s,{sectionId:\"worksheets-and-execution-details\",anchors:\"\",ancestors:\"\",index:\"1\",children:[(0,n.jsx)(e.h2,{id:\"worksheets-and-execution-details\",children:\"Worksheets and execution details\"}),`\n`,(0,n.jsx)(e.p,{children:\"Use worksheets to keep multiple SQL tabs and return to saved queries. Query history retains the catalog and schema used for execution so you can rerun a statement in its original context.\"}),`\n`,(0,n.jsx)(e.p,{children:\"Inspect execution details for timing, compute, and estimated result or scanned rows. Estimates are not exact row counts. Browse tables and columns to inspect their SQL comments, and refresh the results after changing source data.\"}),`\n`]}),(0,n.jsxs)(s,{sectionId:\"example\",anchors:\"\",ancestors:\"\",index:\"2\",children:[(0,n.jsx)(e.h2,{id:\"example\",children:\"Example\"}),`\n`,(0,n.jsx)(e.p,{children:\"Join product usage to account data from another catalog:\"}),`\n`,(0,n.jsx)(e.pre,{children:(0,n.jsx)(e.code,{className:\"language-sql\",children:`SELECT\n  accounts.name,\n  COUNT(*) AS sessions\nFROM product_analytics.analytics.web_sessions sessions\nJOIN crm.public.accounts accounts\n  ON sessions.account_id = accounts.id\nWHERE sessions.started_at >= now() - INTERVAL '7 days'\nGROUP BY accounts.name\nORDER BY sessions DESC\nLIMIT 20;\n`})}),`\n`]}),(0,n.jsxs)(s,{sectionId:\"when-to-use-it\",anchors:\"\",ancestors:\"\",index:\"3\",children:[(0,n.jsx)(e.h2,{id:\"when-to-use-it\",children:\"When to use it\"}),`\n`,(0,n.jsxs)(e.p,{children:[\"Use SQL Explorer for fast iteration and one-off checks. Build a \",(0,n.jsx)(e.a,{href:\"/docs/data-apps\",children:\"data app\"}),\" when the query should become an interactive report, and use the \",(0,n.jsx)(e.a,{href:\"/docs/lakehouse/query/http-api\",children:\"HTTP API\"}),\" when application code needs to run queries programmatically.\"]}),`\n`]}),(0,n.jsxs)(s,{sectionId:\"learn-more\",anchors:\"\",ancestors:\"\",index:\"4\",children:[(0,n.jsx)(e.h2,{id:\"learn-more\",children:\"Learn more\"}),`\n`,(0,n.jsxs)(e.ul,{children:[`\n`,(0,n.jsxs)(e.li,{children:[(0,n.jsx)(e.strong,{children:(0,n.jsx)(e.a,{href:\"/docs/lakehouse/sql-engine\",children:\"SQL engine\"})}),\": DuckDB dialect and cross-catalog queries.\"]}),`\n`,(0,n.jsxs)(e.li,{children:[(0,n.jsx)(e.strong,{children:(0,n.jsx)(e.a,{href:\"/docs/lakehouse/query/http-api\",children:\"HTTP API\"})}),\": run SQL from scripts and applications.\"]}),`\n`]})]})]})}function u(t={}){let{wrapper:e}=t.components||{};return e?(0,n.jsx)(e,{...t,children:(0,n.jsx)(d,{...t})}):d(t)}function h(t,e){throw new Error(\"Expected \"+(e?\"component\":\"object\")+\" `\"+t+\"` to be defined: you likely forgot to import, pass, or provide it.\")}return S(L);})();\n;return Component;"},"_id":"docs/lakehouse/query/sql-explorer.mdx","_raw":{"sourceFilePath":"docs/lakehouse/query/sql-explorer.mdx","sourceFileName":"sql-explorer.mdx","sourceFileDir":"docs/lakehouse/query","contentType":"mdx","flattenedPath":"docs/lakehouse/query/sql-explorer"},"type":"Docs","path":"/lakehouse/query/sql-explorer","level":3,"parent":"lakehouse/query"}