semantic-view-patterns

Applies optimization patterns to Snowflake semantic view dimensions, metrics, filters, and relationships.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? When root cause analysis or audits reveal gaps in a Snowflake semantic view—such as wrong aggregations, missing joins, or misunderstood columns—this Skill provides a structured library of targeted fix patterns instead of ad-hoc edits. ## Core Features & Use Cases - Dimension and Fact Enhancement: Enrich existing physical columns with descriptions, synonyms, sample values, and unique flags (new physical columns cannot be added). - Metric, Filter, and Relationship Creation: Add calculated aggregations, named WHERE-clause filters, and validated table joins with primary key verification. - Custom Instructions as Last Resort: Apply generalized business logic instructions only when semantic view elements cannot express the requirement. - Use Case: After a debug session finds that generated SQL uses SUM instead of COUNT DISTINCT for customer counts, load the metric optimization pattern and create a UNIQUE_CUSTOMERS metric via semantic_view_set.py. ## Quick Start Ask the AI to fix the wrong aggregation in the semantic view by adding a distinct customer count metric using the optimization patterns.

Frequently Asked Questions about semantic-view-patterns

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

FAQPage Schema
How do I fix wrong aggregations in a Snowflake semantic view?▼

Add a metric with the correct aggregate expression, such as COUNT(DISTINCT customer_id), using the metric optimization pattern. Apply it through semantic_view_set.py with a create operation, then validate that generated SQL uses the new metric.

How to add a relationship between tables in a semantic view?▼

First verify at least one table has a primary key on the join columns, then validate the join with relationship_creation.py. If it succeeds, apply the relationship via semantic_view_set.py with the generated name, columns, cardinality, and join type.

Can I add new dimensions or facts to a semantic view?▼

No. Dimensions and facts are physical database columns and cannot be added through this Skill. You can only enhance their metadata with descriptions, synonyms, sample values, and the unique flag.

When should I use custom instructions in a semantic view?▼

Use custom instructions only as a last resort after dimensions, metrics, relationships, and filters cannot express the logic. Keep them generalized rather than query-specific, and prefer module_custom_instructions when neither type exists yet.

Why does relationship validation fail in a semantic view?▼

Validation often fails when neither table has a primary key, producing a rejected many_to_many relationship, or when reflect_semantic_model rejects the join. If validation fails, remove the relationship and use custom instructions instead.