semantic-view-modeling-patterns

Applies 14 cataloged modeling patterns to Snowflake Semantic View YAML definitions.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Modeling non-trivial analytics scenarios in Snowflake Semantic Views—year-over-year comparisons, SCD2 temporal joins, snapshot balances, funnel pipelines, multi-path relationships—requires specific YAML constructs that are easy to get wrong, producing deploy errors or silently inflated numbers. ## Core Features & Use Cases - Pattern Catalog: 14 documented patterns (time intelligence, ASOF/range joins, semi-additive metrics, window metrics, accumulating snapshots, role-playing dimensions, derived metrics, multi-fact tables, computed join keys, AI metadata, diagnostics) each with working YAML snippets and binding gotchas. - Diagnostics Guide: Maps six failure modes (ambiguous paths, fan traps, missing relationships, duplicate names, wrong cardinality, forgotten semi-additivity) to exact error messages and broken/fixed YAML pairs. - Guided Workflow: Steps for retrieving the target SV, adapting snippet placeholders, dry-run validating with SYSTEM$CREATE_SEMANTIC_VIEW_FROM_YAML, and smoke-testing after deploy. - Use Case: A user asks for a loan funnel metric (applied → reviewed → decided → funded). The skill loads the accumulating_snapshot snippet, adapts it to the target SV's tables, validates the YAML, and verifies each stage metric buckets by its own milestone date. ## Quick Start Load this skill and ask to add a year-over-year revenue comparison to my semantic view YAML.

Frequently Asked Questions about semantic-view-modeling-patterns

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

FAQPage Schema
How do I add year-over-year comparison to a Snowflake semantic view?▼

Use the time intelligence pattern: create a role-playing alias of the fact table, define a computed fact that shifts the date with DATEADD, and join it to the calendar dimension via that computed key. This aligns prior-year rows into current period buckets without window functions.

How do I model SCD2 slowly changing dimensions in a semantic view?▼

Use the range join pattern with unique_keys on (key, valid_from, valid_to), a constraints distinct_range block, and a relationship column with type: range plus right_range. If the dimension only has a start date with no end date, use the ASOF join pattern instead.

Why does my semantic view query show inflated numbers?▼

Inflated numbers usually come from a wrong primary_key declaration (wrong cardinality) or summing a snapshot fact across time. Verify the declared PK is actually unique, and add non_additive_dimensions to snapshot metrics like balances or headcount.

What causes the multi-path relationship not supported error?▼

This error occurs when a fact table has two foreign keys to the same dimension and a metric is grouped by that dimension without disambiguation. Fix it by adding using_relationships to each metric, naming which relationship path to follow.

Can a semantic view metric join on a computed column?▼

Yes. Define a fact with a scalar row-level expression (for example CONCAT of year and quarter), then reference that fact's logical name as left_column in the relationship. Aggregation expressions are not valid as join keys.

How do I validate semantic view YAML before deploying?▼

Run CALL SYSTEM$CREATE_SEMANTIC_VIEW_FROM_YAML with the third argument set to TRUE, which validates the YAML structure without creating the view. This catches deploy-time errors like duplicate names and reversed relationship direction early.