Solve: How to Find Broken Views in Redshift with a Calm Python Script


Solve: How to Find Broken Views in Redshift with a Calm Python Script


It usually starts the same way. A dashboard fails, or a query throws an error:


Bash
ERROR: relation "staging.transactions_2022" does not exist  


In Redshift, this kind of error often comes from a broken view—and more specifically, a view created with late binding. Redshift allows you to create views without validating the existence of the underlying tables or columns. That flexibility speeds up development. But it also opens the door to silent system rot.


One view breaks. Then you wonder: how many more?

This happened recently in a Redshift environment we were helping assess. And rather than fixing one view at a time, we built a small tool to check the health of every view in the system. The goal wasn’t automation or cleanup. The goal was clarity.


A Simple Python Tool to Scan Redshift Views

We built a Python script that connects to Redshift, lists all the views, and tries to run an EXPLAIN on each one. If a view is broken—because of a missing table, column, or schema mismatch—Redshift will throw an error. We catch that and log the view as "Broken."

It produces a clean, readable text report like this:


Bash
Redshift View Health Report
Generated: 2025-04-04 22:15:31

View: public.sales_summary
Status: Healthy

View: analytics.monthly_rollup
Status: Broken
Error: relation "staging.transactions_2022" does not exist


The script takes just seconds to run, even on large clusters. And the output is something a dev, a data engineer, or a manager can all understand.

You can download and run the tool yourself here:

👉 View on GitHub Gist


When to Run It

This tool is best run when:
  • A view throws an unexpected error
  • You've made schema changes to underlying tables
  • You're auditing a Redshift environment you inherited
  • You want to know what else might be broken before it becomes a support ticket

It's not magic. But it's clear. And sometimes clarity is exactly what Redshift is missing.

Special thanks to the engineers and real-world scenarios that inspired this. We'll keep building tools that make old systems a little more honest.


Need AWS Expertise?

We're happy to help you with your AWS projects!  Feel free to contact us.



Image: Gemini

Comments

Popular posts from this blog

The New ChatGPT Reason Feature: What It Is and Why You Should Use It

Raspberry Pi Connect vs. RealVNC: A Comprehensive Comparison

The Reasoning Chain in DeepSeek R1: A Glimpse into AI’s Thought Process