debugging-snowflake-queries

This skill should be used when a user needs help debugging a Snowflake SQL query, understanding a Snowflake query failure, isolating incorrect results, fixing joins or filters, diagnosing performance problems, or turning a vague warehouse error into a concrete root cause and corrected query. It is a standalone Snowflake query debugging skill for ad hoc SQL work across databases, schemas, and environments.

Category: Development

About this skill

This skill should be used when a user needs help debugging a Snowflake SQL query, understanding a Snowflake query failure, isolating incorrect results, fixing joins or filters, diagnosing performance problems, or turning a vague warehouse error into a concrete root cause and corrected query. It is a standalone Snowflake query debugging skill for ad hoc SQL work across databases, schemas, and environments.

Source and installation instructions

Documentation

Debugging Snowflake Queries

Debug Snowflake SQL systematically: reproduce the failure, classify the problem, isolate the smallest failing unit, verify grain and joins, and only then rewrite the query.

When to Use

Do Not Use For

Workflow

  1. Reproduce the exact failing query or reconstruct the smallest equivalent query.
  2. Classify the issue before changing SQL:
    • compile/name-resolution
    • permissions/environment
    • type/cast/null semantics
    • join/grain/result correctness
    • performance/scan/warehouse
    • stale or incomplete upstream data
  3. Reduce the query to the smallest failing component:
    • one CTE at a time
    • one join at a time
    • one computed expression at a time
    • one filter at a time
  4. Verify object existence, schema, and exact column names before assuming anything.
  5. State the grain of each input and intermediate result explicitly.
  6. Validate counts and null rates around every join boundary.
  7. When a query is logically wrong but syntactically valid, prove the failure mode with a targeted counterexample or diagnostic query.
  8. Only after isolating the root cause, rewrite the full query.

Core Rules

References

Load these references as needed:

Expected Output

When returning a debugging answer:

  1. State the likely root cause in one sentence.
  2. Show the minimal diagnostic evidence.
  3. Provide the corrected query or exact fix.
  4. Note any remaining assumptions, especially around grain, environment, or upstream freshness.