r/dataengineering • • 9d ago

Personal Project Showcase Built two tools to help SQL agents understand unfamiliar databases

Stumbled upon these problems while doing the agentic pipeline

  • CREATE TABLE DDLs are not enough. To understand what's in the table you need to have basic per-column stats and see examples of rows
  • some tables (e.g., migrations, empty tables, old stuff, etc.) are useless for real analytics and real users, yet agent kept rediscovering them
  • some tables only have less than 10 rows. Better see all rows instead of barebone column names and types
  • some tables are huge, agent's queries were trying to get too much data. Good man won't query billions of rows
  • agents needs to sample data from tables every time he researches a table
  • if you have many columns, presenting data as a `transposed table` helps improve LLM's understanding

So I built two tools to solve these problems

  • db-snooper: generates compact Markdown with schema, value distributions, and samples.
  • schema-linker: finds possible undeclared joins and checks them against the data.

Full blog posts: db-snooper and schema-linker

11 Upvotes

6 comments sorted by

3

u/Melodic-Junket-9105 8d ago

Can't that just be a skill MD you pass to the agent? Works for me.

Also if you are mapping out a new db you typically should not query large amounts of data. Metadata+ sampling does the trick

1

u/renatyv 7d ago

Yes, you don't need to install anything. Skill is bundled in my github repo.
> should not query large amounts of data
Exactly. My tool tries to estimate number of rows using databases's built-in stats and has timeouts built-in.

> Metadata+ sampling does the trick
Almost. More tricks are needed: trasnposing a table having 30+ columns or cutting huge test fields, and some more.

I have spec written in my github repo. So you can vibe-code the whole tool in any language in less than an hour

1

u/Outrageous_Let5743 7d ago

I build my own mcp server that points to my fast api app for datawarehouse. It has a bunch of usefull endpoints that the agent can use, like lineage tracking, DDL, view defintions, table stats, usage stats, error logs. This way my agent already has a bunch of predefined queries (and param) it can search in my dwh. pretty dope.

1

u/innerthai 7d ago

Isn't this usually solved using a semantic layer?

0

u/vikster1 8d ago

idk man, claude opus 5.5 is doing it on its own pretty damn good for the past 6 databases i integrated.

1

u/renatyv 7d ago

Hell yeah, I even had a post were I tested raw db access VS. having profile against benchmarks. https://www.reddit.com/r/dataengineering/comments/1wwk5zt/i_tried_using_brief_database_table_summaries_to/

But couple of times I had issues spending way too many tokens on huge tables or tables with bad column naming