Cover of Business Intelligence with Agents, edition 2026.11.3, code G6KS-JFJ2 Business Intelligence with Agents G6KS-JFJ2 3 editions since Nov 2026 Rolling Edition 2026.11.3

Business Intelligence with Agents

Edition 2026.11.3 Examples passed Nov 6, 2026 78 of 78 examples pass What changed

Written with AI. Verified by people. How we make books

Anyone can check this book or correct it. Report an error · How to fix one

Agents that turn business questions into trusted insights, from your warehouse: layered context, governed metrics in a semantic layer, guarded SQL, answers that say when they can't be given, access rules the agent can't talk its way past, and evaluation on your own golden questions, served over MCP, all on DuckDB, sqlglot and MetricFlow.

Who it's for For analytics engineers, BI developers and data scientists who write SQL, know their warehouse, and have been asked to let people ask the data questions, with an assistant that gets the number right.

Start reading

Labs

Work through this book in the Lab

Run every example exactly as the book did, change the code to see what happens, and try your own ideas on the book's code and data. Nothing to install, and your work is saved. Opens in about 30 seconds.

Run every example exactly as the book did, change the code to see what happens, and try your own ideas on the book's code and data. Nothing to install, and your work is saved. Included with membership: 20 hours a month with Member, or 60 with Member Plus.

Edition history3 editions since November 2026Every edition and what it changed
2026.11.12026.11.3
2026.11.3 · Nov 6, 2026Library update3 sections changed, 74 examples on new versions

Contents

11 chapters, about 4 hours 35 minutes to read or 6 hours 11 minutes to listen to, with 78 examples.

  1. 1A data agent end to end

    By the end of this chapter, you can build the shop's warehouse, have a recorded model write SQL for a business question, run that SQL and catch the wrong number it returns, answer the same question from one defined metric, and score both approaches on five golden questions.

  2. 2Where raw text-to-SQL gets the number wrong

    By the end of this chapter, you can name the five ways schema-only text-to-SQL returns a plausible wrong number on a real warehouse, show each one on the shop's warehouse, count them across a set of golden questions, and tell which a better prompt can fix and which need definitions the schema doesn't hold.

  3. 3Build golden questions from your own work

    By the end of this chapter, you can write golden questions from the questions people in your business ask, each with its golden SQL, the role that asks it and the kind of answer it needs.

  4. 4Give the agent layered context

    By the end of this chapter, you can give a model that writes SQL more than the schema, in layers: notes on columns whose names mislead, a glossary of the shop's business terms, and verified queries retrieved for each question.

  5. 5Define metrics once in a semantic layer

    By the end of this chapter, you can write the shop's semantic models and metrics in MetricFlow's YAML spec, compile a metric request to SQL with the book's own compiler, show that its entity joins can't fan out, group by the fiscal calendar, and confirm that MetricFlow compiles the same definitions to the same results.

  6. 6Route questions to governed metrics first

    By the end of this chapter, you can give the agent the semantic layer's metrics as tools instead of the warehouse's tables, have it return a structured metric request that's validated before anything runs, have it ask the person back when a question could mean several metrics, and measure the change on the golden questions.

  7. 7Let the agent write SQL inside guards

    By the end of this chapter, you can handle the questions no metric covers by letting the agent write SQL that runs read-only on a database holding only the rows and columns its role may read, and that is parsed, checked against an allowlist of tables, bounded in rows, size, cost and time, repaired once from an error, and transpiled to your warehouse's dialect.

  8. 8Say when the answer can't be given

    By the end of this chapter, you can make declining a first-class answer: tell the questions the warehouse can't answer from the ones it can, decline with a reason of a known kind, check that the data for the period asked about has arrived, show the provenance behind every answer, and measure declines with precision and recall, so the agent neither guesses nor refuses too often.

  9. 9Keep the agent inside who may see what

    By the end of this chapter, you can enforce each role's row filters, column masks and minimum group size below the agent, in the role's own database, with the rewrite in the semantic layer and the SQL guard as defence in depth, so that no prompt can widen access.

  10. 10Judge answers and catch regressions

    By the end of this chapter, you can score a run of the agent on several measures at once, use a model as a judge only where results can't be compared directly, calibrate that judge against reference labels anyone can recompute, see how much a score moves from one run to the next, and gate a change to prompts, context or metrics in CI on recorded runs.

  11. 11Serve the semantic layer over MCP

    By the end of this chapter, you can serve the shop's governed metrics as MCP tools that answer for the role the server was built for, return each answer with its provenance as structured data, test the server in memory, and run the book's agent through it as a host.

Cite this section

Format

Every format names this edition. Its link opens the current edition, where a section’s heading says when its text last changed. Accessed and retrieved dates are the day you open this.