Chuyển đến nội dung
Skillpedia
Cơ sở dữ liệu29k · #9523

snowflake-development

Skill này làm gì

Skill này cung cấp cho agent các mẫu SQL và pipeline dữ liệu Snowflake thực tế. Skill dành cho kỹ sư dữ liệu và nhà phân tích xây dựng hoặc sửa công việc trên nền tảng dữ liệu Snowflake.

Khi nào nên dùng

  • ✓Khi bạn cần một lệnh MERGE upsert hoặc một Dynamic Table cho dữ liệu Snowflake.
  • ✓Khi một truy vấn Snowflake chậm hoặc trả về một lỗi bạn không hiểu.
  • ✓Khi bạn muốn dùng các hàm Snowflake Cortex AI trong một truy vấn.

Liên kết skill

https://github.com/alirezarezvani/claude-skills/blob/main/engineering-team/snowflake-development/skills/snowflake-development/SKILL.md

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/alirezarezvani/claude-skills/blob/main/engineering-team/snowflake-development/skills/snowflake-development/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Viết một lệnh MERGE Snowflake để upsert các dòng khách hàng mới từ bảng staging vào bảng customers.”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Agent viết SQL theo các thực hành tốt của Snowflake, như danh sách cột rõ ràng và CTE, và có thể tạo template cho MERGE, Dynamic Tables và cấp quyền. Nó cũng giúp với code Snowpark Python.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

Snowflake Development

Snowflake SQL, data pipelines, Cortex AI, and Snowpark Python development. Covers the colon-prefix rule, semi-structured data, MERGE upserts, Dynamic Tables, Streams+Tasks, Cortex AI functions, agent specs, performance tuning, and security hardening.

Originally contributed by James Cha-Earley — enhanced and integrated by the claude-skills team.

Quick Start

# Generate a MERGE upsert template
python scripts/snowflake_query_helper.py merge --target customers --source staging_customers --key customer_id --columns name,email,updated_at

# Generate a Dynamic Table template
python scripts/snowflake_query_helper.py dynamic-table --name cleaned_events --warehouse transform_wh --lag "5 minutes"

# Generate RBAC grant statements
python scripts/snowflake_query_helper.py grant --role analyst_role --database analytics --schemas public,staging --privileges SELECT,USAGE

SQL Best Practices

Naming and Style

  • Use snake_case for all identifiers. Avoid double-quoted identifiers -- they force case-sensitive names that require constant quoting.
  • Use CTEs (WITH clauses) over nested subqueries.
  • Use CREATE OR REPLACE for idempotent DDL.
  • Use explicit column lists -- never SELECT * in production. Snowflake's columnar storage scans only referenced columns, so explicit lists reduce I/O.

Stored Procedures -- Colon Prefix Rule

In SQL stored procedures (BEGIN...END blocks), variables and parameters must use the colon : prefix inside SQL statements. Without it, Snowflake treats them as column identifiers and raises "invalid identifier" errors.

-- WRONG: missing colon prefix
SELECT name INTO result FROM users WHERE id = p_id;

-- CORRECT: colon prefix on both variable and parameter
SELECT name INTO :result FROM users WHERE id = :p_id;

This applies to DECLARE variables, LET variables, and procedure parameters when used inside SELECT, INSERT, UPDATE, DELETE, or MERGE.

Semi-Structured Data

  • VARIANT, OBJECT, ARRAY for JSON/Avro/Parquet/ORC.
  • Access nested fields: src:customer.name::STRING. Always cast with ::TYPE.
  • VARIANT null vs SQL NULL: JSON null is stored as the string "null". Use STRIP_NULL_VALUE = TRUE on load.
  • Flatten arrays: SELECT f.value:name::STRING FROM my_table, LATERAL FLATTEN(input => src:items) f;

MERGE for Upserts

MERGE INTO target t USING source s ON t.id = s.id
WHEN MATCHED THEN UPDATE SET t.name = s.name, t.updated_at = CURRENT_TIMESTAMP()
WHEN NOT MATCHED THEN INSERT (id, name, updated_at) VALUES (s.id, s.name, CURRENT_TIMESTAMP());

See references/snowflake_sql_and_pipelines.md for deeper SQL patterns and anti-patterns.


Data Pipelines

Choosing Your Approach

Approach When to Use
Dynamic Tables Declarative transformations. Default choice. Define the query, Snowflake handles refresh.
Streams + Tasks Imperative CDC. Use for procedural logic, stored procedure calls, complex branching.
Snowpipe Continuous file loading from cloud storage (S3, GCS, Azure).

Dynamic Tables

CREATE OR REPLACE DYNAMIC TABLE cleaned_events
    TARGET_LAG = '5 minutes'
    WAREHOUSE = transform_wh
    AS
    SELECT event_id, event_type, user_id, event_timestamp
    FROM raw_events
    WHERE event_type IS NOT NULL;

Key rules:

  • Set TARGET_LAG progressively: tighter at the top of the DAG, looser downstream.
  • Incremental DTs cannot depend on Full-refresh DTs.
  • SELECT * breaks on upstream schema changes -- use explicit column lists.
  • Views cannot sit between two Dynamic Tables in the DAG.

Streams and Tasks

CREATE OR REPLACE STREAM raw_stream ON TABLE raw_events;

CREATE OR REPLACE TASK process_events
    WAREHOUSE = transform_wh
    SCHEDULE = 'USING CRON 0 */1 * * * America/Los_Angeles'
    WHEN SYSTEM$STREAM_HAS_DATA('raw_stream')
    AS INSERT INTO cleaned_events SELECT ... FROM raw_stream;

-- Tasks start SUSPENDED. You MUST resume them.
ALTER TASK process_events RESUME;

See references/snowflake_sql_and_pipelines.md for DT debugging queries and Snowpipe patterns.


Cortex AI

Function Reference

Function Purpose
AI_COMPLETE LLM completion (text, images, documents)
AI_CLASSIFY Classify text into categories (up to 500 labels)
AI_FILTER Boolean filter on text or images
AI_EXTRACT Structured extraction from
Câu hỏi thường gặp

Skill có tạo sẵn các template SQL không?

Có. Một script hỗ trợ tạo template cho upsert MERGE, Dynamic Tables và các lệnh cấp quyền truy cập.

Skill có bao quát các tính năng AI trong Snowflake không?

Có. Skill bao quát các hàm Cortex AI và đặc tả agent (agent spec).

Skill khuyên dùng phong cách SQL nào?

Skill khuyên đặt tên theo snake_case, dùng CTE và danh sách cột rõ ràng, thay vì SELECT * trong môi trường production.

Chi tiết

Mô tả gốc của tác giả

Use for Snowflake work: SQL, Dynamic Tables, Streams and Tasks, Cortex AI functions and agents, Snowpark Python, dbt on Snowflake, or Snowflake errors. Helps with queries via snowflake_query_helper.py.

repo: alirezarezvani/claude-skills

Độ phổ biến

Sao GitHub
29k
Vị trí xếp hạng
#9523
Giấy phép
MIT
Cập nhật
2/11/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự