How DataHub uses unstructured context to generate accurate SQL for agents | DataHub
Generating SQL from natural language sounds simple until the query requires business knowledge that isn't in your schema. "Generate a query for total trade volume on commercial real estate loan trades over the past quarter with a safe loan-to-value ratio" — that question requires an AI agent to know two things your database can't tell it: what counts as a real estate loan specifically, and what your organization considers a safe LTV. Without that context, the agent either guesses or asks the user to fill in the gaps. In this demo from the DataHub December 2025 Town Hall, Co-Founder John Joyce shows how DataHub's context graph solves this by searching through connected Notion documents to find the organization's own commercial loan underwriting guidelines. DataHub surfaces the relevant definition — a safe LTV for commercial real estate is 75% or less — and embeds that business rule directly into the generated SQL. The LTV threshold doesn't come from a generic financial definition or a model assumption. It comes from the organization's own documented policy, referenced and cited in the query output. What makes this significant is the contrast with what happens without unstructured context. In an earlier example in the same demo, the agent lacked enough context to generate the right SQL and had to prompt the user to fill in the gaps. With the context graph pulling from Notion documents, DataHub fills those gaps autonomously, scanning three or four source documents and synthesizing the relevant business rules into a single, accurate SQL statement. This is the core capability DataHub's context graph is built around: connecting unstructured knowledge sources like Notion wikis, Confluence pages, internal policy documents, and business glossaries to the structured metadata graph, so that AI agents can reason about your data the way a knowledgeable data practitioner would, not just a system that can read table names. 🧠 What is context management? https://datahub.com/blog/context-management/ 🔍 DataHub data discovery: https://datahub.com/products/data-discovery/ ➖ FIND MORE ABOUT DATAHUB 🚀 Join the DataHub open source community ▶︎ https://hubs.la/Q03YmhK20 🔍 Take the DataHub interactive product tour ▶︎ https://hubs.la/Q03Ymjqp0 ➡️ Explore DataHub's blog ▶︎ https://hubs.la/Q03YmjLN0 ➖ LinkedIn: https://www.linkedin.com/company/datahub-cloud/ X: https://x.com/DataHubCloud #ContextGraph #UnstructuredData #DataHub #AIAgents #SQLGeneration #BusinessGlossary #ContextManagement #Notion #Metadata