选项
首页首页 Skill 数据库管理 snowflake-semanticview

snowflake-semanticview

github/awesome-copilot github/awesome-copilot

使用 Snowflake CLI(snow)创建、修改及验证 Snowflake 语义视图。当需要通过 CREATE/ALTER SEMANTIC VIEW 语句构建或排查语义视图/语义层定义的问题、通过 CLI 对语义视图的 DDL 语句进行验证,或是指导 Snowflake CLI 的安装与连接配置时,均可使用该工具。

...展开全部
17
更新时间 2026-08-23

关于 snowflake-semanticview

本技能将指导助手使用官方 Snowflake CLI(snow)创建、修改及验证 Snowflake 语义视图。它通过遵循严格的“先验证后操作”工作流程,解决了构建可靠语义层定义的问题:助手不会直接生成未经测试的 DDL,而是先起草 CREATE/ALTER SEMANTIC VIEW 语句,通过 CLI 使用临时名称在 Snowflake 中对其进行验证,反复调整直至通过验证,最后才应用最终定义。此外,它还提供了安装 Snowflake CLI 以及通过 snow connection add 配置连接的一次性设置指南,并会引用 Snowflake 的官方文档。

该工作流程十分严谨。它会要求助手确认目标数据库、模式、角色、数据仓库以及视图名称,验证星型模型结构,并依据官方语法起草 DDL。对于每一个维度、事实表和度量指标,它都会要求填写别名和注释,优先使用 Snowflake 中已有的列注释作为依据,在创建新注释前会先征得用户许可。它还会使用带有 DISTINCT 关键字且行数限制在 1000 行以内的只读 SELECT 语句来识别数据关联关系和列类型,通过带有临时后缀(如 __tmp_validate)的名称对 DDL 进行验证,以避免覆盖真实视图,随后运行示例 SEMANTIC_VIEW 查询来确认功能表现,最后清理临时生成的对象。

该技能的目标用户是那些需要构建 Snowflake 语义层或度量指标定义的数据工程师和分析工程师。凭证管理由 Snowflake 官方 CLI 的连接配置功能负责,而非由本技能处理;同时,通过使用临时验证名称、限制行数上限以及在创建注释前征得许可等设计,体现了谨慎且低风险的数据处理理念。

常见问题

需要哪些前置条件?

必须已安装 Snowflake CLI(snow),并通过 snow connection add 配置好连接。本技能会链接到 Snowflake 的官方文档以指导安装和连接设置,这些步骤均为一次性操作。

凭证是如何处理的?

身份验证工作由 Snowflake 官方 CLI 的连接配置功能负责。本技能会使用已配置的连接进行验证和执行操作,本身不会存储或管理任何凭证。

它是如何避免覆盖现有视图的?

它会使用临时名称对 DDL 进行验证,例如在相同的数据库和模式中添加 __tmp_validate 之类的后缀,只有在验证成功后才会应用最终 DDL,并随后清理临时对象。

它会查询我的实际数据吗?

它会运行带有 DISTINCT 关键字且行数限制在 1000 行以内的只读 SELECT 语句,以此识别事实表与维度表之间的关联关系以及列类型,从而生成有意义的注释和别名。

它会自行创建别名或注释吗?

不会。它会优先使用 Snowflake 中已有的列注释作为依据,在添加任何新内容之前,会先询问用户是否允许创建注释、是否需要用户提供具体文本,或是是否应先给出建议供用户审批。

在 GitHub 上查看

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 add per 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

  1. Confirm the target database, schema, role, warehouse, and final semantic view name.
  2. Confirm the model follows a star schema (facts with conformed dimensions).
  3. Draft the semantic view DDL using the official syntax:
    • https://docs.snowflake.com/en/sql-reference/sql/create-semantic-view
  4. 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.
  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.
  6. Create a temporary validation name (for example, append __tmp_validate) while keeping the same database and schema.
  7. Always validate by sending the DDL to Snowflake via Snowflake CLI before finalizing:
    • Use snow sql to execute the statement with the configured connection.
    • If flags differ by version, check snow sql --help and use the connection option shown there.
  8. If validation fails, iterate on the DDL and re-run the validation step until it succeeds.
  9. Apply the final DDL (create or alter) using the real semantic view name.
  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-viewExample:
SELECT * FROM SEMANTIC_VIEW(    my_semview_name    DIMENSIONS customer.customer_market_segment    METRICS orders.order_average_value)ORDER BY customer_market_segment;
  1. 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

复制 复制
快速设置: 将该技能文件夹复制到 .claude/skills/ 目录中,Claude 会自动检测并使用该技能。

相关技能

microservices-patterns
更新时间 2026-06-29
jpa-patterns
更新时间 2026-06-30
fabric-lakehouse
更新时间 2026-06-30
prisma-expert
更新时间 2026-06-29
OR