Your warehouse has 240 tables named things like f_pto_agg and d_wfm_fclty_pop_dfntn_mnl.
No table or column comments. No dbt docs, no ERD, no data model anyone kept up to date. Unity Catalog or Snowflake is there, but nobody filled in the descriptions, so there’s nothing for a tool to build a semantic model from.
The one engineer who knows how these tables join just gave notice. And your VP wants a text-to-SQL agent.
So you’re stuck choosing. Write the semantic layer by hand, table by table, for six months. Or push raw table names into a vector DB and watch retrieval miss. Someone asks about “approved time-off requests,” and the right table is f_pto_agg. Those share zero words, so embeddings have nothing to match on.
A new paper from Amazon and USC takes a different route: skip the docs and mine your query logs.
Every JOIN your analysts ever wrote is sitting in your query history. Those logs already record which tables go together, on which keys, and how often.
I rebuilt the first stage in Python with sqlglot and DuckDB on TPC-DS (24 tables, zero declared keys). From 99 queries, the parser pulled 79 join edges. The top one showed up 64 times, and the catalog had no record of it.
What I took away from the paper:
→ The graph replaces the YAML. Tables become nodes, joins become edges weighted by how often people use them. On Amazon’s warehouse that meant 1,847 edges from about 500K queries.
→ An LLM writes the missing docs. Feed Claude 3.7 Sonnet sample queries for each table and it returns descriptions, filters, and business terms like “employee” and “time-off” as JSON.
→ Entities first, embeddings last. Exact term matches get 0.5 weight, substring matches 0.3, embeddings 0.2, then Personalized PageRank finds the bridge tables. On the BEAVER benchmark, 95.7% of its SQL ran without errors, against 60.8% for plain embedding retrieval. Amazon’s data engineers preferred it 70% to 10%.
→ Read the numbers twice. “Runs without errors” isn’t “correct.” On questions with one right answer, human-written SQL still won 64.9% to 26.3%. The BEAVER test had no query logs at all. And logs carry your team’s old mistakes, deprecated joins included.
The video shows the moment it clicks. The full article has the sqlglot code, a stack guide by warehouse size (NetworkX for small, Neo4j when teams share the graph), and my critique.
How is your team handling undocumented tables for LLM agents: semantic layer, or query logs?
#DataEngineering #TextToSQL #GraphRAG #LLM #DuckDb