semantic-view-filters-and-metrics-suggestions

Generate metric, filter, and fact suggestions for Snowflake semantic views from query history.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Defining metrics, filters, and facts for a Snowflake semantic view by hand means guessing which aggregations and filters users actually need. This Skill mines real Snowflake query history via SYSTEM$CORTEX_ANALYST_SVA_TOOL to surface the metrics, named filters, and computed facts people already use, so the semantic view reflects actual usage patterns. ## Core Features & Use Cases - Query-history-driven suggestions: Calls the filters_and_metrics_suggestions tool to recommend metrics, named filters, computed facts, and primary keys based on verified queries. - Structured result parsing: Uses PARSE_JSON with LATERAL FLATTEN to convert the raw JSON response into readable, per-suggestion rows with frequency and justification metadata. - Actionable next steps: Presents suggestions grouped by type and sorted by frequency, then offers to apply them to the semantic view using semantic_view_set.py. - Use Case: After creating a semantic view over ticket sales data, ask for metric suggestions and receive recommendations like total_revenue (SUM(price)) with usage frequency, ready to append to the view. ## Quick Start Suggest metrics and filters for my semantic view ANALYTICS.PUBLIC.TICKET_SALES using my current warehouse.

Frequently Asked Questions about semantic-view-filters-and-metrics-suggestions

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

FAQPage Schema
How do I get metric suggestions for a Snowflake semantic view?▼

Call SYSTEM$CORTEX_ANALYST_SVA_TOOL with the filters_and_metrics_suggestions tool, passing the fully qualified semantic view name and warehouse. Wrap the result in PARSE_JSON with LATERAL FLATTEN to read each suggestion as a separate row.

How to suggest filters and facts from Snowflake query history?▼

The filters_and_metrics_suggestions tool mines query history and verified queries to recommend named filters, computed facts, and metrics. Each suggestion includes an expression, description, frequency count, and justification for why it was recommended.

Can I use filters_and_metrics_suggestions with a stage-based semantic model file?▼

Yes, pass semantic_model_file with the stage path (for example @DB.SCHEMA.STAGE/model.yaml) instead of the semantic_view parameter. The same JSON parsing workflow applies to the returned suggestions.

Why does the suggestions function return zero rows?▼

Zero rows usually means insufficient query history for the semantic view. Add more tables to the model or run representative queries first, then execute the function again to generate suggestions.

Why should I avoid running SELECT SYSTEM$CORTEX_ANALYST_SVA_TOOL directly?▼

The raw function returns a large JSON string that gets truncated when displayed directly, making it unreadable. Always wrap it with PARSE_JSON and LATERAL FLATTEN, and avoid CREATE TABLE AS since the function has side effects.