semantic-view-creation

Generate Snowflake semantic views from SQL queries and table metadata using the FastGen system function.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve? Creating a Snowflake semantic view by hand requires writing complex YAML with tables, dimensions, measures, relationships, and verified queries, which is error-prone and slow. This Skill automates the entire creation workflow using the FastGen system function, with a manual fallback when FastGen fails. ## Core Features & Use Cases - Automated FastGen Generation: Builds and validates a FastGen request JSON, executes SYSTEM$CORTEX_ANALYST_FAST_GENERATION, and extracts the resulting YAML with pagination via RESULT_SCAN. - Validation and Enhancement: Validates the generated model with SYSTEM$CREATE_SEMANTIC_VIEW_FROM_YAML in verify-only mode, and optionally infers primary keys and relationships using helper scripts. - Manual Fallback Workflow: Falls back to a manual creation path using infer_primary_keys.py and extract_table_metadata.py when FastGen fails due to permissions, warehouse, or syntax errors. - Use Case: A data engineer provides SQL queries against ANALYTICS.LOGS.USAGE_LOGS and receives a validated semantic model YAML with dimensions, metrics, relationships, and VQRs ready for audit or deployment to Snowflake. ## Quick Start Ask the assistant to create a new semantic view named usage_analytics in your target database and schema from your SQL queries.

Frequently Asked Questions about semantic-view-creation

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

FAQPage Schema
How do I create a Snowflake semantic view from SQL queries?▼

Provide your SQL queries, target database, and schema, then the workflow builds a FastGen request JSON and calls SYSTEM$CORTEX_ANALYST_FAST_GENERATION. The generated semantic model YAML is saved to disk and validated with SYSTEM$CREATE_SEMANTIC_VIEW_FROM_YAML in verify-only mode.

What is the FastGen system function in Snowflake?▼

FastGen (SYSTEM$CORTEX_ANALYST_FAST_GENERATION) is a Snowflake system function that automatically generates semantic models from table metadata and SQL queries. It infers primary keys, relationships, dimensions, measures, and creates verified queries from provided SQL.

What happens if FastGen fails during semantic view creation?▼

The workflow falls back to a manual creation path using infer_primary_keys.py and extract_table_metadata.py scripts. Common FastGen failures include table access permissions, inactive warehouses, invalid column names, and insufficient role privileges.

Why must I store the query ID immediately after running FastGen?▼

LAST_QUERY_ID() is volatile and changes with every query execution, so the FastGen query ID must be stored in a variable immediately. All subsequent extraction uses RESULT_SCAN with the stored ID to paginate YAML output without re-executing the expensive function.

Which relationship types are supported in Snowflake semantic models?▼

Only many_to_one and one_to_one relationship types are valid in the semantic model YAML. Many-to-many relationship suggestions from FastGen are automatically filtered out, and the right-side table must have a primary key defined.