snowflake-data-engineering
FreeNo executable scriptsNot checkedBest practices for Snowflake SQL, semi-structured data, and data pipelines built with Dynamic Tables, Streams, Tasks, and Snowpipe. Use when writing Snowflake…
by Mindrally★ 323 GitHub starsAbout this skill
Snowflake Data Engineering
This skill covers SQL conventions, pipeline architecture (Dynamic Tables, Streams, Tasks, Snowpipe), performance tuning, and cost/access management on Snowflake.
Workflow for Building a Snowflake Pipeline
- Land raw data — Use Snowpipe (
AUTO_INGEST = TRUE) for continuous file loads from an external stage, or Snowpipe Streaming for low-latency row-level ingestion via SDK. - Choose a transformation approach — Prefer Dynamic Tables for declarative, most pipelines; fall back to Streams + Tasks only when you need procedural logic or stored-procedure calls.
- Model semi-structured data — Land raw JSON/Avro/Parquet as
VARIANT, then flatten into typed relational columns as early as practical. - Chain pipeline stages — Build Dynamic Tables on top of each other (or Streams feeding Tasks) so each stage narrows scope from raw to cleaned to aggregated.
- Tune for performance — Add clustering keys or Search Optimization only where query patterns justify them; tag queries for cost attribution.
- Set access controls — Apply least-privilege RBAC with functional roles (loader, transformer, analyst) and masking/row-access policies for sensitive data.
- Monitor cost and freshness — Track
WAREHOUSE_METERING_HISTORYandQUERY_HISTORY, set Resource Monitors, and validateTARGET_LAGmatches actual freshness requirements.
SQL and Semi-Structured Data
- Use
VARIANT,OBJECT, andARRAYtypes for JSON, Avro, Parquet, and ORC data. - Access nested fields with colon notation and cast explicitly:
src:customer.name::STRING,src:price::NUMBER(10,2),src:created_at::TIMESTAMP_NTZ. - Flatten arrays with
LATERAL FLATTEN:
SELECT f.value:name::STRING AS name
FROM my_table, LATERAL FLATTEN(input => src:items) f;
- Flatten semi-structured data into relational columns whenever it contains dates, numbers stored as strings, or arrays — keeping data inside
VARIANTprevents Snowflake's automatic subcolumnarization from paying off. - Avoid mixing types within the same
VARIANTfield for the same reason. - Remember that a JSON
nullis stored as the string"null", distinct from a SQLNULL. UseSTRIP_NULL_VALUES => TRUEon load when you want them treated the same.
SQL coding standards
- Use
snake_casefor all identifiers; avoid quoted identifiers. - Prefer CTEs over deeply nested subqueries for readability.
- Use
CREATE OR REPLACEfor idempotent DDL. - Use
COPY INTOfor bulk loading, never row-by-rowINSERT. - Use
MERGEfor upserts:
MERGE INTO target t USING source s ON t.id = s.id
WHEN MATCHED THEN UPDATE SET t.name = s.name
WHEN NOT MATCHED THEN INSERT (id, name) VALUES (s.id, s.name);
- In stored procedures, prefix session/local variables with
:when referencing them inside SQL statements:
CREATE PROCEDURE my_proc(p_id INT) RETURNS STRING LANGUAGE SQL AS
BEGIN
LET result STRING;
SELECT name INTO :result FROM users WHERE id = :p_id;
RETURN result;
END;
Performance Optimization
- Add cluster keys only for very large tables (multi-TB) on columns frequently used in
WHERE/JOIN/GROUP BY:
ALTER TABLE large_events CLUSTER BY (event_date, region);
- Use the Search Optimization Service for point lookups on high-cardinality columns or substring/regex search:
ALTER TABLE logs ADD SEARCH OPTIMIZATION ON EQUALITY(sender_ip), SUBSTRING(error_message);
- Use Materialized Views to pre-compute expensive single-table aggregations.
- Reuse prior results with
RESULT_SCAN(LAST_QUERY_ID())instead of re-running an identical query. - Tag queries for cost attribution:
ALTER SESSION SET QUERY_TAG = 'etl_daily_load'; - Never run
SELECT *on wide tables — it defeats columnar pruning benefits.
Data Pipelines
Choose the right primitive:
| Approach | When to use |
|---|---|
| Dynamic Tables | Declarative: define the query, Snowflake manages refresh. Default choice for most pipelines. |
| Streams + Tasks | Imperative CDC + scheduling; needed for procedural logic or stored-procedure calls. |
| Snowpipe | Continuous file loading from S3/GCS/Azure. |
| Snowpipe Streaming | Low-latency row-level ingestion via SDK (Java, Python). |
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_data:page::STRING AS page, event_timestamp
FROM raw_events
WHERE event_type IS NOT NULL;
-- Chain for multi-step pipelines
CREATE OR REPLACE DYNAMIC TABLE user_sessions
TARGET_LAG = '10 minutes'
WAREHOUSE = transform_wh
AS
SELECT user_id, MIN(event_timestamp) AS session_start, MAX(event_timestamp) AS session_end,
COUNT(*) AS event_count
FROM cleaned_events GROUP BY user_id;
TARGET_LAG sets the freshness target. REFRESH_MODE can be AUTO, FULL, or INCREMENTAL. Manage lifecycle with `ALTER DYNAMIC TABLE ... SET TARGET_LAG / REFRESH /
Install snowflake-data-engineering in Claude Code & Claude Desktop
Sign up to install this skill
Create a free account to reveal the install command and save the skill to your library.
- Reveal the one-line install command
- Save skills to your synced library
- Get notified when skills update
Allowed tools
Tools this skill is permitted to call.
No restriction — this skill can use any tool.
FAQ
What does the snowflake-data-engineering skill do?
Best practices for Snowflake SQL, semi-structured data, and data pipelines built with Dynamic Tables, Streams, Tasks, and Snowpipe. Use when writing Snowflake SQL, designing ingestion or transformation pipelines, tuning warehouse performance and cost, or working with Time Travel, cloning, RBAC, or Iceberg tables on Snowflake.
How do I install the snowflake-data-engineering skill?
Copy the skill folder into ~/.claude/skills (the Claude Code tab above does this in one command), or install it as a plugin.
Does the snowflake-data-engineering skill run scripts?
No, this skill is instructions only (SKILL.md) with no executable scripts.
Related skills
skill-creator
Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an…
by Anthropicdiscernment-nudge
After you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals…
by Anthropicdata-consolidate
Joins the plant's scheduled exports and connector data into one working dataset — ERP items (NetSuite or Infor M3), sales orders, production work orders…
by Anthropicinspection-to-capa
Runs the quality chain end to end: writes the nonconformance against the requirement it violates, searches history at the moment of writing to say whether…
by Anthropic