semantic-view-debug

Diagnoses and fixes SQL generation issues in Snowflake semantic views through iterative optimization.

Updated Jun 9, 2025
One-click install
npx skills add https://github.com/RajaPoseidon/snippets_repo --skill semantic-view-debug-rajaposeidon
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: semantic-view-debug
Source: https://github.com/RajaPoseidon/snippets_repo/tree/main/snowflake/skills/debug
Command: npx skills add https://github.com/RajaPoseidon/snippets_repo --skill semantic-view-debug-rajaposeidon

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? When Cortex Analyst generates incorrect SQL from a Snowflake semantic view, this Skill diagnoses the root cause, applies targeted optimizations to the semantic view YAML, and validates that the fixed SQL produces correct results. ## Core Features & Use Cases - Issue Diagnosis: Generates SQL from problematic natural language questions using Cortex Analyst to reproduce failures. - Root Cause Analysis: Maps SQL errors (missing joins, wrong aggregations, incorrect filters) to specific semantic view gaps like missing relationships, metrics, or synonyms. - Validated Optimization: Applies approved fixes via semantic_view_set.py, then executes both generated and ground truth SQL to confirm results match exactly. - Use Case: A data engineer finds that Cortex Analyst generates SQL missing a hierarchy table join for a revenue question. This Skill identifies the missing relationship in the semantic view, proposes the fix, and validates the corrected query output. ## Quick Start Debug why my semantic view generates wrong SQL for the question "what is total revenue by region last quarter" and fix it.

Frequently Asked Questions about semantic-view-debug

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I fix wrong SQL generated by Cortex Analyst?▼

Provide the failing natural language question, and the Skill generates SQL with the current semantic view, analyzes gaps like missing joins or metrics, and applies approved fixes to the semantic view YAML. It then re-generates and executes the SQL to validate the fix.

How to debug semantic view SQL generation issues in Snowflake?▼

Run the debug workflow after completing semantic view setup: diagnose the issue by generating SQL, perform root cause analysis mapping SQL errors to semantic view gaps, then apply and validate optimizations. Each optimization iteration requires explicit user approval.

What semantic view problems cause incorrect SQL generation?▼

Common gaps include missing relationships between tables causing absent JOINs, missing metric definitions causing wrong aggregations, poorly described dimensions causing missing columns, and missing named filters causing incorrect WHERE clauses.

Does this skill validate fixes against ground truth SQL?▼

Yes, it executes both the optimized generated SQL and any user-provided ground truth SQL, comparing row counts and columns side by side. Without ground truth, it asks the user to review results before declaring success.

What are the prerequisites for debugging a semantic view?▼

You must first complete the semantic-view-setup skill, which loads the setup instructions, creates a workspace directory, and familiarizes you with the semantic view tools. Debugging cannot start without this initialization.