{"title":"Query product data with SQL","description":"Query identity-resolved product events with DuckDB SQL and join product behavior to connected business data using the Product Analytics catalog.","order":780,"askSuggestions":["Should I query raw or identity-resolved events?","How do I join product events with tables from another catalog?"],"navigation":true,"body":{"code":"var Component=(()=>{var y=Object.create;var i=Object.defineProperty;var w=Object.getOwnPropertyDescriptor;var v=Object.getOwnPropertyNames;var f=Object.getPrototypeOf,m=Object.prototype.hasOwnProperty;var g=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports),b=(n,e)=>{for(var a in e)i(n,a,{get:e[a],enumerable:!0})},d=(n,e,a,r)=>{if(e&&typeof e==\"object\"||typeof e==\"function\")for(let o of v(e))!m.call(n,o)&&o!==a&&i(n,o,{get:()=>e[o],enumerable:!(r=w(e,o))||r.enumerable});return n};var x=(n,e,a)=>(a=n!=null?y(f(n)):{},d(e||!n||!n.__esModule?i(a,\"default\",{value:n,enumerable:!0}):a,n)),D=n=>d(i({},\"__esModule\",{value:!0}),n);var h=g((P,l)=>{l.exports=_jsx_runtime});var S={};b(S,{default:()=>p,frontmatter:()=>q});var t=x(h()),q={title:\"Query product data with SQL\",description:\"Query identity-resolved product events with DuckDB SQL and join product behavior to connected business data using the Product Analytics catalog.\",order:780,askSuggestions:[\"Should I query raw or identity-resolved events?\",\"How do I join product events with tables from another catalog?\"]};function u(n){let e={a:\"a\",code:\"code\",h1:\"h1\",h2:\"h2\",p:\"p\",pre:\"pre\",...n.components},{DocsPreviewDocument:a,DocsPreviewSection:r,DocsPrompt:o,DocsPrompts:s}=e;return a||c(\"DocsPreviewDocument\",!0),r||c(\"DocsPreviewSection\",!0),o||c(\"DocsPrompt\",!0),s||c(\"DocsPrompts\",!0),(0,t.jsxs)(a,{anchors:\"query-product-data-with-sql inspect-available-data analyze-with-an-agent\",children:[(0,t.jsxs)(r,{sectionId:\"query-product-data-with-sql\",anchors:\"\",ancestors:\"\",index:\"0\",children:[(0,t.jsx)(e.h1,{id:\"query-product-data-with-sql\",children:\"Query product data with SQL\"}),`\n`,(0,t.jsxs)(e.p,{children:[\"Use SQL when you need a custom analysis or want to join product behavior with another catalog. Use the \",(0,t.jsx)(e.a,{href:\"/docs/product-analytics/data-model\",children:\"identity-resolved views\"}),\" for analysis that should apply identity mappings.\"]}),`\n`]}),(0,t.jsxs)(r,{sectionId:\"inspect-available-data\",anchors:\"\",ancestors:\"\",index:\"1\",children:[(0,t.jsx)(e.h2,{id:\"inspect-available-data\",children:\"Inspect available data\"}),`\n`,(0,t.jsxs)(e.p,{children:[\"Before writing a query, inspect the table schema in \",(0,t.jsx)(e.a,{href:\"/docs/lakehouse/query/sql-explorer\",children:\"SQL Explorer\"}),\" or ask your agent to describe it. Start with a bounded query:\"]}),`\n`,(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:\"language-sql\",children:`SELECT * FROM product_analytics.analytics.events LIMIT 10;\n`})}),`\n`,(0,t.jsxs)(e.p,{children:[\"Use \",(0,t.jsx)(e.code,{children:\"product_analytics.main.events\"}),\" when you need the raw records received by the tracking endpoint. Choose the view based on whether you want raw or identity-resolved data.\"]}),`\n`]}),(0,t.jsxs)(r,{sectionId:\"analyze-with-an-agent\",anchors:\"\",ancestors:\"\",index:\"2\",children:[(0,t.jsx)(e.h2,{id:\"analyze-with-an-agent\",children:\"Analyze with an agent\"}),`\n`,(0,t.jsx)(s,{children:(0,t.jsx)(o,{children:\"Analyze signup conversion over the last month. Where do users drop off?\"})}),`\n`,(0,t.jsxs)(e.p,{children:[\"For visual analyses, use \",(0,t.jsx)(e.a,{href:\"/docs/product-analytics/segmentation\",children:\"segmentation\"}),\", \",(0,t.jsx)(e.a,{href:\"/docs/product-analytics/funnel\",children:\"funnels\"}),\", or \",(0,t.jsx)(e.a,{href:\"/docs/product-analytics/retention\",children:\"retention\"}),\". For an interactive application, \",(0,t.jsx)(e.a,{href:\"/docs/data-apps/build\",children:\"build a data app\"}),\".\"]})]})]})}function p(n={}){let{wrapper:e}=n.components||{};return e?(0,t.jsx)(e,{...n,children:(0,t.jsx)(u,{...n})}):u(n)}function c(n,e){throw new Error(\"Expected \"+(e?\"component\":\"object\")+\" `\"+n+\"` to be defined: you likely forgot to import, pass, or provide it.\")}return D(S);})();\n;return Component;"},"_id":"docs/product-analytics/query.mdx","_raw":{"sourceFilePath":"docs/product-analytics/query.mdx","sourceFileName":"query.mdx","sourceFileDir":"docs/product-analytics","contentType":"mdx","flattenedPath":"docs/product-analytics/query"},"type":"Docs","path":"/product-analytics/query","level":2,"parent":"product-analytics"}