Insight: Visualizing Redshift View Dependencies with Graphviz
A Visual Twist on a Classic Problem
In a recent post, we explored how to trace recursive view dependencies in Amazon Redshift using SQL and Python. That post was inspired by a real Slack question from our teammate Prasad, who needed to understand how one view depended on another across layers of a legacy data platform. If you missed it, check out the full solution here:
Insight: Recursive View Dependencies in Redshift? Here's the Workaround
Today, we’re taking that solution one step further—by visualizing it.
From Tree to Graph: Why It Matters
When you're working with a large set of views, seeing the dependency tree as a visual diagram can change how you think. Instead of squinting at console logs or parsing text output, you get a clean, directional map that shows the flow of data logic. Arrows make the lineage intuitive. Branching highlights architecture flaws. Cycles (if they exist) pop immediately.
To support this, we've added a Graphviz-compatible generator script to the same GitHub Gist from the original article. The script, generate_view_graph_dot.py, takes a list of view dependencies and outputs a DOT file that can be rendered with any Graphviz tool.
Why the Gist Has More Than One Script
We deliberately kept everything in a single GitHub Gist so readers could see the full context: SQL queries, the Python tree walker, and now the DOT file generator. If you're only interested in the visualizer, just use generate_view_graph_dot.py and ignore the rest—but if you're solving the full problem from scratch, the other files are there to help.
Example Output and How to Run It
Here's what a typical DOT file might look like:
To run the generator, simply pass in your list of dependencies:
This will output a view_graph.dot file you can immediately visualize.
Next Steps
The script can be extended to color root nodes, group schemas, or even flag potential bottlenecks. For now, though, it gives you a fast, readable output with minimal effort—perfect for audits, architecture reviews, and data platform onboarding.
If you'd like to see an advanced version or a CLI tool built around this, let us know. We’re always thinking a few steps ahead.
Next Steps
The script can be extended to color root nodes, group schemas, or even flag potential bottlenecks. For now, though, it gives you a fast, readable output with minimal effort—perfect for audits, architecture reviews, and data platform onboarding.
If you'd like to see an advanced version or a CLI tool built around this, let us know. We’re always thinking a few steps ahead.
Need AWS Expertise?
We're happy to help you with your AWS projects! Feel free to contact us.
Email: info@pacificw.com
Image: Gemini
Comments
Post a Comment