snowflake-semanticview
github/awesome-copilot
Snowflake CLI(snow)を使用して、Snowflakeのセマンティックビューを作成、変更、検証します。CREATE/ALTER SEMANTIC VIEWコマンドを用いてセマンティックビューやセマンティックレイヤーの定義を作成したり問題を診断したりする際、CLIを通じてセマンティックビューのDDLをSnowflakeに対して検証したり、Snowflake CLIのインストールや接続設定を手順付けたりする場合に利用します。
...すべて拡張しますsnowflake-semanticviewについて
このスキルでは、公式のSnowflake CLI(snow)を使用してSnowflakeセマンティックビューの作成、変更、検証を行う手順をガイドします。まず厳格で検証を最優先とするワークフローを適用することで、信頼性の高いセマンティックレイヤ定義の構築という課題に対処します。テストされていないDDLを直接生成するのではなく、まずCREATE/ALTER SEMANTIC VIEW文を作成し、一時的な名前を付けてCLIを通じてSnowflakeで検証を行い、合格するまで繰り返し修正を加え、最終的にのみ正式な定義を適用します。また、Snowflake CLIのインストールやsnow connection addを使った接続設定に関する一回限りの設定ガイドも提供し、公式のSnowflakeドキュメントへのリンクも掲載しています。
このワークフローは非常に徹底しており、対象となるデータベース、スキーマ、ロール、ウェアハウス、ビュー名の確認、スタースキーマモデルの検証、公式の構文に基づくDDLの作成といった手順を含みます。各次元、ファクト、メトリクスに対して同義語やコメントの入力も求められ、可能であれば既存のSnowflake列コメントを出典として利用し、新たなコメントを作成する際には事前に許可を得るようにしています。関係性や列の種類を把握するためにDISTINCTと最大1000行のLIMITを設定した読み取り専用のSELECT文を使用し、実際のビューが破損しないように一時的な名前(例:__tmp_validateというサフィックス)でDDLを検証します。その後、SEMANTIC_VIEWクエリのサンプル実行を行って動作を確認し、一時的なオブジェクトは適切に削除します。
対象ユーザーは、Snowflakeセマンティックレイヤやメトリクス定義を構築するデータエンジニアやアナリティクスエンジニアです。認証情報の管理はこのスキルではなく、公式のSnowflake CLI接続設定に委ねられており、一時的な検証名の使用やLIMITの上限設定、コメント作成前の許可取得といった点から、慎重かつリスクの低いデータ処理が意識されています。
よくある質問
前提条件は何ですか?
Snowflake CLI(snow)がインストールされており、snow connection addを使って接続が設定されている必要があります。インストールや接続設定については公式のSnowflakeドキュメントへリンクされており、これらは一回限りの手順として扱われます。
認証情報はどのように管理されますか?
認証処理は公式のSnowflake CLI接続設定に委ねられています。このスキルは設定済みの接続を利用して検証や実行を行うだけで、認証情報自体は管理も保存もしません。
既存のビューを上書きしないようにする仕組みは何ですか?
DDLは一時的な名前、例えば同じデータベースとスキーマ内に__tmp_validateというサフィックスを付けた名前で検証され、検証に成功した後にのみ最終的なDDLが適用され、その後一時的なオブジェクトは削除されます。
実際のデータをクエリしますか?
意味のあるコメントや同義語を作成するために、DISTINCTと最大1000行のLIMITを設定した読み取り専用のSELECT文を実行し、ファクトや次元間の関係性や列の種類を把握します。
同義語やコメントを自動的に作成しますか?
いいえ。既存のSnowflake列コメントを出典として優先的に利用し、新たなコメントを作成する際には事前に許可を求め、テキストの提供を依頼したり、承認用の提案を作成したりします。
One-Time Setup
- Verify Snowflake CLI installation by opening a new terminal and running
snow --help. - 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.
- Configure a Snowflake connection with
snow connection addper https://docs.snowflake.com/en/developer-guide/snowflake-cli/connecting/configure-connections#add-a-connection. - Use the configured connection for all validation and execution steps.
Workflow For Each Semantic View Request
- Confirm the target database, schema, role, warehouse, and final semantic view name.
- Confirm the model follows a star schema (facts with conformed dimensions).
- Draft the semantic view DDL using the official syntax:
- https://docs.snowflake.com/en/sql-reference/sql/create-semantic-view
- Populate synonyms and comments for each dimension, fact, and metric:
- Read Snowflake table/view/column comments first (preferred source):
- https://docs.snowflake.com/en/sql-reference/sql/comment
- 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.
- Read Snowflake table/view/column comments first (preferred source):
- 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.
- Create a temporary validation name (for example, append
__tmp_validate) while keeping the same database and schema. - Always validate by sending the DDL to Snowflake via Snowflake CLI before finalizing:
- Use
snow sqlto execute the statement with the configured connection. - If flags differ by version, check
snow sql --helpand use the connection option shown there.
- Use
- If validation fails, iterate on the DDL and re-run the validation step until it succeeds.
- Apply the final DDL (create or alter) using the real semantic view name.
- 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-viewExample:
SELECT * FROM SEMANTIC_VIEW( my_semview_name DIMENSIONS customer.customer_market_segment METRICS orders.order_average_value)ORDER BY customer_market_segment;
- Clean up any temporary semantic view created during validation.
Synonyms And Comments (Required)
- Use the semantic view syntax for synonyms and comments:
WITH SYNONYMS [ = ] ( 'synonym' [ , ... ] )COMMENT = 'comment_about_dim_fact_or_metric'- Treat synonyms as informational only; do not use them to reference dimensions, facts, or metrics elsewhere.
- Use Snowflake comments as the preferred and first source for synonyms and comments:
- https://docs.snowflake.com/en/sql-reference/sql/comment
- 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.
- Do not invent synonyms or comments without user approval.
Validation Pattern (Required)
- Never skip validation. Always execute the DDL against Snowflake with Snowflake CLI before presenting it as final.
- Prefer a temporary name for validation to avoid clobbering the real view.
Example CLI Validation (Template)
# Replace placeholders with real values.snow sql -q "<CREATE OR ALTER SEMANTIC VIEW ...>" --connection <connection_name>
If the CLI uses a different connection flag in your version, run:
snow sql --help
Notes
- Treat installation and connection setup as one-time steps, but confirm they are done before the first validation.
- Keep the final semantic view definition identical to the validated temporary definition except for the name.
- Do not omit synonyms or comments; consider them required for completeness even if optional in syntax.
すべてのファイル
0件のファイルsnowflake-semanticviewをインストール
該当するスキルファイルをダウンロードし、.claude/skills/ ディレクトリに展開してください。
ZIPをダウンロードリポジトリをクローンし、スキルファイルをプロジェクトにコピーしてください。
git clone https://github.com/github/awesome-copilot/blob/main/skills/snowflake-semanticview/SKILL.md # Copy SKILL.md to your .claude/skills/ directory
コピー





家
