AI Engineer · Published 2026-07-23

AI on Your Lakehouse: Context Comes in Shapes, Not Queries — Zach Blumenfeld, Neo4j

Open on YouTube ↗

Summary

Overview

  • Speaker: Zach Blumenfeld
  • Channel: AI Engineer
  • Main topic: Using knowledge graphs and semantic layers over data lakehouses for AI agents and RAG applications.
  • Purpose: To guide developers and AI engineers on how to combine structured data warehouses and unstructured document storage into a unified graph-based semantic layer that empowers AI agents to reason, query, and act accurately. Zach Blumenfeld from Neo4j presents a hands-on workshop on 'AI on Your Lakehouse,' focusing on why context for AI agents comes in shapes (graphs) rather than flat queries. He covers the challenges of text-to-SQL and vector search in unstructured data lakes, introduces three core graph shapes (Table of Contents, Themes/Communities, and Connections), and demonstrates how tools like neocarta and Neo4j MCP servers bridge data warehouses like BigQuery with graph-powered reasoning.

Topic Map

Introduction and Workshop Setup

  • Explanation: Zach Blumenfeld introduces himself, co-presenters Ben Squire and Ryan Knight, and outlines the workshop based on GraphAcademy and GitHub CodeSpaces.
  • Key claims:
    • Workshops are driven by GraphAcademy courses.
    • Environment setup uses CodeSpaces with pre-configured Neo4j sandboxes and BigQuery credentials.
  • Examples:
    • QR codes provided for course enrollment and credential retrieval.
  • Terminology:
    • GraphAcademy
    • CodeSpaces
    • Anthropic API key
    • BigQuery
  • Why it matters: Establishes the working environment for attendees to follow along with hands-on coding and agentic workflows.

The Context Problem in Lakehouses

  • Explanation: Discussion of the two sides of a lakehouse: structured warehouses (tables) and unstructured data lakes (documents). Explains why vector search and Text2SQL fall short on complex relational schemas and negative queries.
  • Key claims:
    • Text2SQL and vector search find similar meanings in the wrong shapes.
    • Vector search struggles with negative queries (what is missing).
    • Text2SQL fails on complex multi-table joins across hundreds of tables.
  • Examples:
    • AutoFix Group scenario: auto repair chain with vehicle bays, repair logs, manuals, and recall bulletins.
  • Terminology:
    • Vector search
    • Text2SQL
    • Semantic search
    • Lakehouse
  • Why it matters: Highlights the foundational limitation of RAG and prompts the introduction of graph representations for richer context.

The Three Graph Shapes

  • Explanation: Introduces three core concrete graph shapes: Table of Contents (trees), Themes (communities), and Connections (foreign key relationships).
  • Key claims:
    • Context comes in shapes, not queries.
    • Table of contents structures unstructured documents as trees.
    • Themes surface global patterns and groupings from unstructured data.
    • Connections map how database tables join together semantically.
  • Examples:
    • AutoFix Group documentation hierarchy and warehouse foreign key joins.
  • Terminology:
    • Table of contents
    • Themes
    • Connections
    • Ontology
    • Semantic layer
    • Virtual graph
  • Why it matters: Provides a mental model and structural foundation for giving AI agents the exact context needed for accurate reasoning.

Graph Basics and Property Graph Data Model

  • Explanation: Reviews Neo4j property graph fundamentals: nodes, relationships (edges), and properties.
  • Key claims:
    • Graphs consist of nodes, relationships, and properties.
    • Data model acts like pre-joined tables where everything is interconnected for fast traversal.
  • Examples:
    • Person owns/drives Car, Person is brother of Person.
  • Terminology:
    • Property graph data model
    • Node
    • Relationship
    • Property
    • Cypher
  • Why it matters: Ensures audience alignment on graph theory and terminology before diving into code and agent integrations.

Building the Connections Shape with neocarta

  • Explanation: Demonstrates how neocarta reads BigQuery schema metadata and builds a semantic layer graph of foreign key relationships exposed via MCP servers.
  • Key claims:
    • neocarta creates a metadata graph without duplicating raw warehouse data into Neo4j.
    • MCP servers allow AI agents to query database schema and relationships dynamically.
  • Examples:
    • Running python script/build_connections.py to populate foreign key references into Neo4j.
  • Terminology:
    • neocarta
    • MCP server
    • Foreign key
    • Semantic layer graph
  • Why it matters: Solves the Text2SQL join problem by giving agents explicit paths through database schemas.

Building the Outline Shape (Table of Contents)

  • Explanation: Explains how to parse PDFs into hierarchical trees of library, folders, documents, and sections using URI paths for navigation.
  • Key claims:
    • Hierarchical URIs encode tree placement and enable subtree scoping.
    • Combining table of contents trees with full-text search enables precise document traversal.
  • Examples:
    • Parsing PDF manuals into markdown and loading into Neo4j with python scripts/load_documents.py.
  • Terminology:
    • Table of contents
    • Tree containment
    • Hierarchical URIs
    • Full-text search
  • Why it matters: Enables AI agents to navigate massive document libraries top-down instead of relying solely on vector similarity chunks.

Surface Themes and Community Detection

  • Explanation: Applies Graph Data Science (GDS) algorithms like Leiden community detection on cross-reference links between documents to surface hidden themes.
  • Key claims:
    • Leiden community detection groups densely connected documents into thematic clusters.
    • Themes surface global patterns and associations that aren't apparent from isolated search.
  • Examples:
    • Running python scripts/themes.py to generate 13 or 14 thematic clusters from service bulletins and manuals.
  • Terminology:
    • Graph Data Science (GDS)
    • Leiden algorithm
    • Community detection
    • Conductance
    • Themes
  • Why it matters: Allows agents to reason across an entire corpus of documents by understanding overarching subject clusters.

Key Points

Context comes in shapes, not queries

  • Explanation: Traditional RAG uses flat vector search or SQL queries, which often miss holistic relationships and negative constraints. Graphs provide structural shapes that match how humans and agents need to reason.
  • Evidence: Mention of Text2SQL and vector search benchmarks showing high error rates on multi-hop queries.
  • Practical implication: Engineers should construct semantic graph layers over existing data lakehouses rather than relying on naive text queries.

Metadata graph extraction over ETL duplication

  • Explanation: Tools like neocarta extract schema metadata and foreign key relationships into Neo4j without needing to copy massive transactional or warehouse data.
  • Evidence: neocarta reads BigQuery schema and writes REFERENCES edges into Neo4j.
  • Practical implication: Reduces data duplication and synchronization overhead while providing agents with relational intelligence.

Hierarchical URIs for document navigation

  • Explanation: Encoding document hierarchy into URI paths allows agents to scope searches down specific subtrees efficiently.
  • Evidence: Technical library URI structure starting with prefixes like technical-library/bulletins.
  • Practical implication: Improves RAG precision by constraining search spaces to relevant document sections.

Frameworks, Models & Processes

Three Graph Shapes for AI Context

  • How it works: Combines structured warehouse connections, unstructured document trees, and community-detected themes to ground AI agents.
  • Components:
    • Table of Contents (Trees)
    • Themes (Communities)
    • Connections (Relational Schema)
  • When to use: When building advanced AI agents or copilots operating over enterprise data lakehouses with both SQL and document stores.

Examples & Case Studies

AutoFix Group agent needs to find repair instructions for a vehicle code.

  • Illustrates: Combining warehouse work order history with PDF service manuals via graph structures.
  • Lesson: Agents succeed when given both relational join paths and document navigation trees.

Actionable Takeaways

  • Immediate:
    • Use neocarta to map data warehouse schemas into Neo4j.
    • Parse documents into hierarchical trees with URI paths.
    • Apply Leiden community detection for thematic clustering.
  • Strategic:
    • Shift from flat vector retrieval and Text2SQL to graph-grounded agent architectures.
    • Keep data in place in the lakehouse while maintaining a semantic metadata graph.
  • Questions to investigate:
    • How does this pattern scale to billions of nodes across distributed data lakehouses?
    • What are the latency tradeoffs of MCP server roundtrips during agent execution?

Claims Worth Verifying

  • Independent Text2SQL benchmarks report a 78.5% error rate on queries touching four or more tables. (Statistic)
  • Leiden community detection assigns each node a community ID based on structural density. (Technical Fact)

Notable Quotes

"Context comes in shapes, not queries." "Each agents get a slice—never the view to know what's relevant, or how it connects."

Compressed Summary

  • Vector search and Text2SQL fail at complex multi-hop joins and negative queries.
  • Three graph shapes solve context: Table of Contents, Themes, and Connections.
  • neocarta extracts BigQuery metadata into Neo4j without data migration.
  • Hierarchical URIs enable precise subtree scoping in document search.
  • Leiden community detection groups documents into actionable enterprise themes.
  • Keywords: knowledge graph, lakehouse, semantic layer, rag, mcp server, neo4j
  • Core insight: AI agents operating over enterprise lakehouses achieve superior accuracy and reliability when provided with structured graph shapes rather than isolated vector or SQL queries.

Core insights

6
Architecturemedium noveltystrong evidence

The core mental model is that context for AI agents comes in shapes, not queries: a small set of reusable graph shapes—table of contents (trees), themes/communities, and connections (foreign-key joins)—should be constructed over a lakehouse instead of relying on flat vector search or text2SQL.

Why it matters

Provides a concrete architectural vocabulary for semantic layers over mixed structured/unstructured data. Agents can be given graph-shaped context that matches the structure of the problem, rather than arbitrary query results.

Generalization

Any RAG system over a corpus that contains both relational tables and documents can be decomposed into these three shapes; choose which shape to expose based on the reasoning task.

Context comes in shapes, not queries.
Open source video
Table of contents structures unstructured documents as trees.
Open source video
Themes surface global patterns and groupings from unstructured data.
Open source video
Connections map how database tables join together semantically.
Open source video
Failure Modemedium noveltymoderate evidence

Vector search and text2SQL have complementary failure modes: vector search cannot answer negative queries (what is missing) because embedding similarity matches presence, not absence; text2SQL degrades on complex multi-table joins across hundreds of tables.

Why it matters

A naive RAG or agent retrieval stack will silently fail on two important query classes. These failure modes motivate the graph-based semantic layer.

Generalization

When designing retrieval for an agent, identify whether queries are negative/comparative or multi-hop relational; if so, do not rely solely on embeddings or SQL.

Vector search struggles with negative queries (what is missing).
Open source video
Text2SQL fails on complex multi-table joins across hundreds of tables.
Open source video
Mechanismhigh noveltystrong evidence

A metadata graph of warehouse schema (tables and foreign keys) can be extracted into a graph database without duplicating raw warehouse data, then exposed to agents via MCP servers.

Why it matters

This makes graph-powered relational context practical at warehouse scale by avoiding massive ETL duplication and synchronization overhead.

Generalization

Semantic layers over existing data infrastructure should model relationships and metadata first, not full data, giving agents relational intelligence at low cost.

neocarta creates a metadata graph without duplicating raw warehouse data into Neo4j.
Open source video
MCP servers allow AI agents to query database schema and relationships dynamically.
Open source video
Mechanismmedium noveltystrong evidence

Encode document hierarchies as URI paths and combine tree containment with full-text search, enabling agents to navigate large document libraries top-down and scope to subtrees instead of relying on vector similarity chunks.

Why it matters

Provides a precise, structural alternative to embedding-based chunk retrieval, especially useful for technical manuals and nested documentation.

Generalization

If documents are naturally hierarchical, parse them into trees with URI paths and use full-text search within selected subtrees rather than embedding all chunks uniformly.

Hierarchical URIs encode tree placement and enable subtree scoping.
Open source video
Combining table of contents trees with full-text search enables precise document traversal.
Open source video
Mechanismmedium noveltymoderate evidence

Run community detection (e.g., Leiden) on document cross-reference links to surface thematic clusters, giving agents a corpus-level global context that isolated retrieval misses.

Why it matters

Themes enable agents to reason across an entire document corpus, uncovering groups and associations that are invisible to single-document or chunk-level retrieval.

Generalization

Any corpus with citation or cross-reference links can be made navigable by topic via graph community detection; use techniques like conductance to evaluate cluster quality.

Leiden community detection groups densely connected documents into thematic clusters.
Open source video
Running python scripts/themes.py to generate 13 or 14 thematic clusters from service bulletins and manuals.
Open source video
Architecturemedium noveltystrong evidence

Expose the semantic-layer graph to agents through MCP servers as the architectural boundary, so agents can dynamically inspect schema and relationships at runtime rather than using hardcoded database tools.

Why it matters

MCP standardization turns the graph semantic layer into reusable, composable infrastructure that any MCP-compatible agent can use, improving interoperability and reducing bespoke tooling.

Generalization

Agent tooling for knowledge access should be exposed as MCP resources/tools, making relational and document structure dynamically discoverable.

MCP servers allow AI agents to query database schema and relationships dynamically.
Open source video

Deep dives

4

Routing agent queries to graph shapes

Research question

Can an agent reliably select between Connections, Outline, and Themes graph shapes based on query features, and does correct selection improve answer accuracy on heterogeneous lakehouse queries?

Why

The three shapes are a powerful toolbox but no selection policy is described; without routing, agents cannot exploit the right shape.

Context comes in shapes, not queries.
Open source video
Text2SQL and vector search find similar meanings in the wrong shapes.
Open source video
Source video

Negative query limitations of vector retrieval

Research question

Can any embedding-based retrieval method answer negative queries when combined with structured filters, or is symbolic/graph context strictly necessary?

Why

Negative queries are a real class of business questions; assuming vector search handles them leads to silently wrong RAG answers.

Vector search struggles with negative queries (what is missing).
Open source video
Source video

Freshness and consistency of metadata graphs

Research question

What incremental schema synchronization strategy keeps the metadata graph consistent with a rapidly evolving lakehouse, and what freshness threshold avoids agent-visible staleness?

Why

Metadata-only graphs are cheap but become stale if warehouse schema changes are not propagated; stale graph context misleads agents.

neocarta creates a metadata graph without duplicating raw warehouse data into Neo4j.
Open source video
Source video

Hybrid graph and full-text document retrieval

Research question

How should subtree scoping and full-text search be combined so agents can precisely navigate large document libraries?

Why

Hierarchical URIs and full-text search are complementary but the integration algorithm is unspecified; this is a concrete place to improve RAG precision.

Hierarchical URIs encode tree placement and enable subtree scoping.
Open source video
Combining table of contents trees with full-text search enables precise document traversal.
Open source video
Source video

Article ideas

4

RAG Is Missing Its Spine: Why Context Should Come in Shapes, Not Queries

AI agents need graph-shaped context—trees, themes, and connections—rather than flat query results, because structure is what lets them reason over relational and unstructured data together.

Angle

A conceptual argument from the three graph shapes to the architectural implications for semantic layers.

Source video

Text2SQL Is Not a Plan for 200-Table Warehouses

Text2SQL breaks down on deep multi-table joins; representing schema foreign keys as a graph and exposing them through MCP is a more reliable way to give agents relational intelligence.

Angle

Failure-mode analysis plus a metadata-graph alternative.

Source video

The Missing-Data Blind Spot: Why Vector Search Can't Answer 'What Isn't There?'

Embedding similarity is a presence-matching operation, so any RAG system that depends on it will silently fail on negative queries unless it adds a structured graph shape.

Angle

A critique of embedding-only retrieval through the lens of negative/comparative questions.

Source video

Agents Don't Need Your Data Warehouse Copy—They Need Its Schema

Instead of ETL-ing raw warehouse data into a graph, build a metadata graph of tables and foreign keys so agents get relational context at warehouse scale without duplication overhead.

Angle

Practical architecture pattern for semantic layers over lakehouses.

Source video

Project ideas

4

ShapeRouter: Query-to-Shape Routing

movement-lab

A lightweight classifier over query features can select the correct graph shape (Connections, Outline, Themes) with at least 85% accuracy, and correct shape selection improves agent QA accuracy by at least 20% over flat retrieval.

Proof of concept

Simulate the AutoFix scenario with a small BigQuery schema, a manual corpus, and a cross-reference set; generate synthetic queries covering relational, negative, and thematic categories; implement a rule/ML router; run agent answers with each shape.

Measurement

Shape selection accuracy, end-to-end answer accuracy, percent improvement over a flat vector/text2SQL baseline.

Source video

NegBench: Benchmarking Negative-Query Retrieval

beyond-evals

Graph-shaped retrieval (connections) outperforms vector search and text2SQL by at least 30% accuracy on negative queries in a controlled lakehouse benchmark.

Proof of concept

Build a synthetic auto repair dataset with vehicles, bays, repaired logs, manuals, and recall bulletins; define negative queries like 'vehicles with no recorded fix'; compare responses from vector RAG, text2SQL, and graph-shaped model; score manually or with LLM judge.

Measurement

Answer accuracy, precision/recall of retrieved evidence, failure rate on negative queries.

Source video

SchemaSync: Keeping Metadata Graphs Fresh

new

An event-driven poller over BigQuery INFORMATION_SCHEMA can keep the metadata graph consistent with <5 minute lag, reducing stale-schema agent errors by at least 50% compared to nightly rebuilds.

Proof of concept

Create a small script/service that detects schema/foreign-key changes, updates a Neo4j metadata graph, and exposes change timestamps; simulate DDL changes; compare agent queries before/after sync.

Measurement

Schema staleness lag, stale-schema query failure rate, sync overhead.

Source video

DocTree Navigator: Subtree-Scoped Document RAG

new

Scoping full-text search to graph-selected subtrees improves retrieval precision@5 by at least 25% over flat vector search on hierarchical document libraries.

Proof of concept

Parse a public technical manual into URI trees; build a graph with cross-reference links and community themes; evaluate queries against flat vector RAG and subtree-scoped full-text retrieval.

Measurement

precision@5, recall@10, answer completeness judged by LLM.

Source video

Architectural implications

4

A lakehouse has two separate sides: structured tables in a warehouse and unstructured documents in a data lake, and current retrieval treats them separately.

Before

Text-to-SQL and vector search are distinct, flat query paths with separate failure modes.

After

A unified graph semantic layer represents both sides as shapes: connections for table relationships, outline and themes for documents.

Consequence

An agent can answer questions that require crossing relational joins and document structure by traversing graph topology rather than fusing independent query results.

Source video

Using a graph database usually implies loading domain data into the graph, which is expensive for large warehouses.

Before

To get graph reasoning, you duplicate raw warehouse tables into Neo4j.

After

Extract only schema metadata and foreign-key references into Neo4j (as with neocarta), leaving raw data in BigQuery.

Consequence

Relational context is available without data duplication and sync overhead, but row-level values remain outside the graph and must be fetched from the warehouse.

Source video

Document RAG typically embeds chunks and retrieves by vector similarity, losing structure.

Before

Documents are flat chunks; retrieval depends entirely on embedding similarity.

After

Documents are parsed into hierarchical URI trees, enabling subtree scoping, full-text search, and graph-based theme detection.

Consequence

Agents gain top-down navigation and corpus-level awareness, improving precision on structural and thematic queries.

Source video

Agent tools are often custom and tightly coupled to one specific database or query interface.

Before

Each agent integration has bespoke database tools or SQL-generation prompts.

After

The semantic-layer graph is exposed via an MCP server, making schema and relationships dynamically available.

Consequence

Tooling becomes a standardized infrastructure layer, and agents can explore available schema and relationships at runtime.

Source video

Tradeoffs and failure modes

4

Vector search vs. negative queries

Benefit

Good semantic similarity retrieval over unstructured content.

Cost or risk

Fails on negative queries ('what is missing') because embeddings match present information, not absent information.

Vector search struggles with negative queries (what is missing).
Open source video
Source video

Text2SQL vs. graph connections

Benefit

Natural language access to structured warehouse tables.

Cost or risk

Fails on complex multi-table joins across hundreds of tables; the connections shape solves this by making join paths explicit.

Text2SQL fails on complex multi-table joins across hundreds of tables.
Open source video
Source video

Metadata-only graph vs. full data graph

Benefit

Avoids duplicating raw warehouse data, reducing ETL and synchronization overhead.

Cost or risk

Graph contains schema and relationships only, not actual data values, so answering specific row-level queries still requires querying the warehouse.

neocarta creates a metadata graph without duplicating raw warehouse data into Neo4j.
Open source video
Source video

Hierarchical document parsing

Benefit

Enables precise top-down navigation and subtree scoping for large document sets.

Cost or risk

Requires PDF/document parsing into URI trees; quality depends on source structure, and not all documents fit a clean hierarchy.

Hierarchical URIs encode tree placement and enable subtree scoping.
Open source video
Source video

Open questions

4

How should an agent decide which graph shape (connections, outline, themes) to consult for a given user query?

Why unresolved

The three shapes are presented as a toolbox, but the summary does not describe a routing mechanism or policy for selecting among them.

Research direction

Create a router or agent policy that classifies queries by structural need (negative, multi-hop, thematic) and selects the corresponding shape.

Source video

How can the metadata graph stay consistent with a rapidly evolving warehouse schema?

Why unresolved

neocarta reads BigQuery schema at build time; schema changes would require re-sync or event-driven updates, which are not detailed in the summary.

Research direction

Evaluate incremental schema sync strategies and freshness thresholds for semantic-layer metadata graphs.

Source video

What quantitative benchmarks demonstrate the superiority of graph-shaped context over vector/text2SQL for multi-hop and negative queries?

Why unresolved

The summary cites high error rates from benchmarks but gives no numbers, baseline, or methodology.

Research direction

Design a controlled evaluation comparing answer accuracy on multi-hop and negative queries across vector search, text2SQL, and graph-shaped retrieval.

Source video

How can full-text search and graph traversal be optimally combined for document library agents?

Why unresolved

Hierarchical URIs and full-text search are described as complementary, but the integration algorithm is not specified.

Research direction

Prototype hybrid retrieval that scopes full-text queries to subtrees selected via graph traversal or community membership.

Source video

Key claims

6
opinionVerification not requested

Text2SQL and vector search find similar meanings in the wrong shapes.

Evidence

Text2SQL and vector search find similar meanings in the wrong shapes.

Source video
factualVerification needed

Vector search struggles with negative queries (what is missing).

Evidence

Vector search struggles with negative queries (what is missing).

Question

Can any vector retrieval method answer negative queries if combined with filtering or structured constraints?

Source video
factualVerification needed

Text2SQL fails on complex multi-table joins across hundreds of tables.

Evidence

Text2SQL fails on complex multi-table joins across hundreds of tables.

Question

At what schema complexity does text2sql degrade, and does schema linking significantly improve it?

Source video
factualVerification needed

neocarta creates a metadata graph without duplicating raw warehouse data into Neo4j.

Evidence

neocarta creates a metadata graph without duplicating raw warehouse data into Neo4j.

Question

Does neocarta handle only foreign keys or also other semantic relationships such as synonyms or business terms?

Source video
factualVerification needed

Leiden community detection groups densely connected documents into thematic clusters.

Evidence

Leiden community detection groups densely connected documents into thematic clusters.

Question

Are these clusters validated against human-labeled theme annotations?

Source video
factualVerification needed

MCP servers allow AI agents to query database schema and relationships dynamically.

Evidence

MCP servers allow AI agents to query database schema and relationships dynamically.

Question

Which MCP tools are exposed, and how does an agent discover and invoke them at runtime?

Source video

Connections

5