Docs & Code Guide

Snowflake schema diagram automation: ACCOUNT_USAGE has the object graph, mind its lag

The object graph of a Snowflake account is already stored inside the account. SNOWFLAKE.ACCOUNT_USAGE lists every database, schema, table, and view, and OBJECT_DEPENDENCIES records which objects are built on which. That makes the diagram a query away, with one catch the automation has to respect: ACCOUNT_USAGE runs behind reality, by minutes to hours depending on the view.

7 min readFor data teams who want the warehouse map to survive contact with next sprint

See it as a diagram

Everything below, as a diagram you can edit. Describe yours and see it in seconds.

188/20003 credits left
Try:

No account needed · Editable canvas, not a picture

Two catalogs, one lag: pick per question

Snowflake gives you two ways to read its own metadata, and they disagree on scope and freshness. SNOWFLAKE.ACCOUNT_USAGE covers the whole account from one place, keeps rows for dropped objects with a DELETED timestamp, and lags: up to about two hours for most views, and anywhere from 45 minutes to three hours across the full set. Each database's INFORMATION_SCHEMA is the opposite: real time and lag-free, but scoped to one database, showing only objects your role can see, with no memory of anything dropped.

For a whole-account map, ACCOUNT_USAGE is the right base: one connection, every database, history included. For verifying that an object exists right now, SHOW OBJECTS IN DATABASE or an INFORMATION_SCHEMA query is the check. A regeneration loop typically uses both: ACCOUNT_USAGE for the graph, a SHOW pass to confirm the freshly deployed objects the lagging views have not caught up to yet.

Edges from OBJECT_DEPENDENCIES

The edges of the diagram, which view reads which table, which materialized view is built on what, live in SNOWFLAKE.ACCOUNT_USAGE.OBJECT_DEPENDENCIES as referencing and referenced object pairs. One query returns the dependency graph for the whole account, and Snowflake documents this particular view's latency at up to three hours, the slow end of the ACCOUNT_USAGE range, which is worth knowing before you wire it into automation.

-- Edges: which objects are built on which (latency up to ~3 hours)
SELECT referencing_database, referencing_schema, referencing_object_name,
       referenced_database,  referenced_schema,  referenced_object_name
FROM snowflake.account_usage.object_dependencies;

-- Nodes that exist right now, no lag, one database at a time
SHOW OBJECTS IN DATABASE analytics;

Databases and schemas already are your zones

Most Snowflake estates are layered on purpose: a RAW database for landed data, STAGING for cleaned models, ANALYTICS for marts, or the dbt-style equivalent inside one database with schemas per layer. Map databases to top-level zones and schemas to groups inside them and the diagram inherits the architecture your team already enforces with grants and naming.

Warehouses are the one Snowflake object class to think twice about. They are compute, not storage, and they hold no data edges. Draw them only when the diagram is answering who pays for what or what runs where; on a pure object map they are noise.

Scheduling the redraw, and respecting the lag

The first diagram is a paste away: the Snowflake diagram generator turns a described or exported structure into an editable canvas. Keeping it current is where the metadata queries earn their keep. An agent connected to Datadef's MCP server, registry name io.datadef/mcp, can run the two queries above and update the diagram in place: schedule that agent from CI cron, or invoke it as the last step of the pipeline that changes the warehouse, a dbt run's completion being the natural hook. Datadef does not connect to Snowflake or poll it; the agent you run does the reading, with a Datadef API key from settings, on paid plans.

The lag shapes the schedule. A redraw fired ten minutes after a deploy will not see the new views in OBJECT_DEPENDENCIES yet. Either delay the regeneration past the latency window, or have the deploying pipeline tell the agent what changed, which a dbt manifest already knows, and let ACCOUNT_USAGE confirm on the next scheduled pass.

A task is a trigger, not a redraw

A Snowflake TASK on a CRON schedule can detect schema changes by diffing metadata, but it cannot call your agent. Let the task write a change flag if you like; the regeneration itself runs where your automation lives, in CI or a scheduled runner.

The lag, and other fine print

OBJECT_DEPENDENCIES records dependencies between object definitions. It does not know that a BI dashboard queries a mart table every morning, because ad hoc reads are usage, not structure; read-side lineage is a different problem with different sources, covered from the catalog angle in keeping a data dictionary in sync.

And the standing limits of the surface: a diagram embedded live in a wiki or README requires the project shared public, so a confidential warehouse layout may belong in an exported image instead. Datadef also stays out of your prose; it keeps the object map current, not the model documentation around it.

FAQ

How can I automatically generate a diagram of Snowflake objects?

Query the metadata Snowflake already keeps: SNOWFLAKE.ACCOUNT_USAGE.TABLES and VIEWS for the nodes, OBJECT_DEPENDENCIES for the edges, then feed the result to a generator. With Datadef the loop is an MCP-connected agent running those queries on a schedule or after each deploy and updating the diagram in place.

What is the difference between ACCOUNT_USAGE and INFORMATION_SCHEMA for diagramming?

ACCOUNT_USAGE is account-wide, remembers dropped objects, and lags reality by 45 minutes to three hours depending on the view. INFORMATION_SCHEMA is real time but scoped to one database and your role's visibility, with no history. Build the map from ACCOUNT_USAGE and verify current existence with SHOW or INFORMATION_SCHEMA.

Why is my regenerated Snowflake diagram missing objects I just deployed?

Almost always the ACCOUNT_USAGE lag: OBJECT_DEPENDENCIES can run up to three hours behind. Regenerate after the latency window, or have the deploying pipeline pass the change list to the agent directly, since your dbt manifest or migration scripts already know what was just created.

Should warehouses appear on a Snowflake architecture diagram?

Only when the diagram is about compute: cost attribution, workload isolation, which team runs on which warehouse. On an object and dependency map, warehouses add boxes without edges, since they store nothing and depend on nothing.

Does Datadef connect to my Snowflake account?

No. Datadef renders and serves the diagram; the metadata queries are run by your agent or pipeline, which then updates the diagram through the MCP server using an API key. Your Snowflake credentials never touch Datadef.