FIX
← Signals
Data & AI

LLMs for eCommerce data analysis: talking to your data in plain English

How to build a safe text-to-SQL layer over an eCommerce data warehouse (Magento, Shopify, Klaviyo, GA4) so marketing and founders can ask questions in natural language and get reliable answers.

10 Giu 2026 · 10 min · Alberto Sepe

eCommerce text-to-SQL is an AI interface that turns natural-language questions ('how much did I sell last week vs last year, excluding Black Friday?') into SQL against the data warehouse, executes them and returns the answer with a chart. It absorbs 70% of the 'please pull a report' requests currently saturating the data team.

Stack we use: warehouse on BigQuery or Postgres, a semantic layer (Cube.js or dbt metrics) that exposes pre-aggregated metrics and security constraints, an LLM (Claude or GPT-4o) that generates SQL only against authorized views, an executor with hard timeout and row limit, a renderer that picks table vs chart.

The semantic layer is what makes it safe and reliable. Without it, the LLM invents JOINs between raw tables and returns plausible but false numbers. With a semantic model, the AI composes validated metrics: 'revenue', 'orders', 'AOV', 'active customers' have one definition.

Security: read-only DB user, schema whitelist, prompt-injection filter, full audit log of every query and requester. Never let the LLM run DDL or mutate data. Row-level security per team: marketing sees everything but COGS, finance sees margins, a 'client' role only sees its own brand if the warehouse is multi-tenant.

The game-changer for eCommerce is cross-source correlation in one question: 'Which categories have the best ROAS in the last 30 days AND the worst 90-day retention?' The AI joins Magento, GA4 and Meta Ads data without anyone designing the report.

Typical setup on a €15M/yr client: 3 weeks to implement, ~1,200 monthly queries generated, 68% drop in ad-hoc requests to the data team. LLM cost ~€180/month. Payback well under 3 months.

What changes for commercial and marketing teams

The most visible organizational impact isn't on data analysts — it's on marketing and founders. When a CMO can ask at 10pm 'which Meta campaigns have CAC above €40 in the last 14 days' and get an answer in 8 seconds, decision pace changes. The 'I'll wait for Tuesday's report' queue disappears. Weekly meetings shrink because everyone shows up with data they've already explored on their own.

Real limits (where it still fails)

Text-to-SQL doesn't work well on questions requiring business judgment ('which SKUs should we drop from the catalog?'), on non-trivial statistical correlations (cohort retention curves adjusted for seasonality), or on questions phrased too ambiguously ('how are sales?' — which metric? Which period? Compared to what?). The agent should ask for clarification here — if it doesn't, it invents and causes damage. A good system prompt forces clarification before generating SQL on vague requests.

Typical 90-day roadmap

Week 1–2: warehouse audit and defining the first 15 core metrics in the semantic layer. Week 3–4: text-to-SQL agent against secure views, internal testing with 5–10 users. Week 5–8: rollout to marketing and commercial, feedback loop to refine prompts and synonyms (every client has its own vocabulary — 'active customers', 'buyers', 'users' can mean different things). Week 9–12: real-usage monitoring, adding new metrics based on the most frequent questions, Slack integration for on-the-fly queries.

Want to talk?

Every signal comes from a real project.

Get in touch →