Snowflake Semantic Views

Snowflake Semantic Views

Guides the AI to draft, alter and validate Snowflake semantic view DDL with the Snowflake CLI, checking star schema design and filling synonyms and comments.

Skill files1 file
SKILL.md84 lines
1
---
2
name: snowflake-semanticview
3
description: Create, alter, and validate Snowflake semantic views using Snowflake CLI (snow). Use when asked to build or troubleshoot semantic views/semantic layer definitions with CREATE/ALTER SEMANTIC VIEW, to validate semantic-view DDL against Snowflake via CLI, or to guide Snowflake CLI installation and connection setup.
4
---
5
6
# Snowflake Semantic Views
7
8
## One-Time Setup
9
10
- Verify Snowflake CLI installation by opening a new terminal and running `snow --help`.
11
- If Snowflake CLI is missing or the user cannot install it, direct them to https://docs.snowflake.com/en/developer-guide/snowflake-cli/installation/installation.
12
- Configure a Snowflake connection with `snow connection add` per https://docs.snowflake.com/en/developer-guide/snowflake-cli/connecting/configure-connections#add-a-connection.
13
- Use the configured connection for all validation and execution steps.
14
15
## Workflow For Each Semantic View Request
16
17
1. Confirm the target database, schema, role, warehouse, and final semantic view name.
18
2. Confirm the model follows a star schema (facts with conformed dimensions).
19
3. Draft the semantic view DDL using the official syntax:
20
- https://docs.snowflake.com/en/sql-reference/sql/create-semantic-view
21
4. Populate synonyms and comments for each dimension, fact, and metric:
22
- Read Snowflake table/view/column comments first (preferred source):
23
- https://docs.snowflake.com/en/sql-reference/sql/comment
24
- If comments or synonyms are missing, ask whether you can create them, whether the user wants to provide text, or whether you should draft suggestions for approval.
25
5. Use SELECT statements with DISTINCT and LIMIT (maximum 1000 rows) to discover relationships between fact and dimension tables, identify column data types, and create more meaningful comments and synonyms for columns.
26
6. Create a temporary validation name (for example, append `__tmp_validate`) while keeping the same database and schema.
27
7. Always validate by sending the DDL to Snowflake via Snowflake CLI before finalizing:
28
- Use `snow sql` to execute the statement with the configured connection.
29
- If flags differ by version, check `snow sql --help` and use the connection option shown there.
30
8. If validation fails, iterate on the DDL and re-run the validation step until it succeeds.
31
9. Apply the final DDL (create or alter) using the real semantic view name.
32
10. Run a sample query against the final semantic view to confirm it works as expected. It has a different SQL syntax as can be seen here: https://docs.snowflake.com/en/user-guide/views-semantic/querying#querying-a-semantic-view
33
Example:
34
35
```SQL
36
SELECT * FROM SEMANTIC_VIEW(
37
my_semview_name
38
DIMENSIONS customer.customer_market_segment
39
METRICS orders.order_average_value
40
)
41
ORDER BY customer_market_segment;
42
```
43
44
11. Clean up any temporary semantic view created during validation.
45
46
## Synonyms And Comments (Required)
47
48
- Use the semantic view syntax for synonyms and comments:
49
50
```
51
WITH SYNONYMS [ = ] ( 'synonym' [ , ... ] )
52
COMMENT = 'comment_about_dim_fact_or_metric'
53
```
54
55
- Treat synonyms as informational only; do not use them to reference dimensions, facts, or metrics elsewhere.
56
- Use Snowflake comments as the preferred and first source for synonyms and comments:
57
- https://docs.snowflake.com/en/sql-reference/sql/comment
58
- If Snowflake comments are missing, ask whether you can create them, whether the user wants to provide text, or whether you should draft suggestions for approval.
59
- Do not invent synonyms or comments without user approval.
60
61
## Validation Pattern (Required)
62
63
- Never skip validation. Always execute the DDL against Snowflake with Snowflake CLI before presenting it as final.
64
- Prefer a temporary name for validation to avoid clobbering the real view.
65
66
## Example CLI Validation (Template)
67
68
```bash
69
# Replace placeholders with real values.
70
snow sql -q "<CREATE OR ALTER SEMANTIC VIEW ...>" --connection <connection_name>
71
```
72
73
If the CLI uses a different connection flag in your version, run:
74
75
```bash
76
snow sql --help
77
```
78
79
## Notes
80
81
- Treat installation and connection setup as one-time steps, but confirm they are done before the first validation.
82
- Keep the final semantic view definition identical to the validated temporary definition except for the name.
83
- Do not omit synonyms or comments; consider them required for completeness even if optional in syntax.
84

© GitHub, Inc. · MIT · source · posted by @OpenSourceBuffGuy on promptparty.com

@OpenSourceBuffGuy

I find openly licensed prompts and post them here.

0 followers · 14,621 prompts

More by @OpenSourceBuffGuy

See all
Sea turtle carrying floating film studio island prompt image

Sea turtle carrying floating film studio island

Draws a giant sea turtle carrying a floating island film studio through a starry sky, where fairies polish rough film strips into golden film.

image-prompt, nano-banana, 3d-render, cartoon, fantasy-world, creatures, animals, whimsical, dreamy, cinematic, dramatic-lighting, vibrant-colors, bokeh, miniature, widescreen, night-scene, illustration, concept-art, surreal, storytelling, clay-3d

Desert buggy escapes drones past industrial outpost prompt image

Desert buggy escapes drones past industrial outpost

Builds a 15-second desert chase video where a racer in an armored buggy escapes drones past an industrial outpost, using five reference images with set jobs.

video-prompt, hailuo, action, multi-shot, timed-beats, camera-movement, reference-image, character-consistency, negative-prompt, cinematic, sci-fi, cars, landscape, aerial-view, tracking-shot, photorealistic, sound-effects, structured-output, long-form, widescreen

1 view
Cozy Pixel Art Farm Island Village prompt image

Cozy Pixel Art Farm Island Village

Draws a cozy 16-bit pixel-art farming village across six small islands joined by bridges, with exact counts for buildings, animals and crops.

image-prompt, gpt-image, pixel-art, isometric, game-assets, concept-art, maps, worldbuilding, cozy, vibrant-colors, ocean, landscape, wide-shot, widescreen, game-development, video-games, structured-output, whimsical, summer, high-angle, aerial-view, animals, negative-prompt, cityscape

1 view

Reviews

Loading reviews…

Discussion

Loading comments…