mindrally/skills/snowflake-snowpark-dbt
- community
Checking that the SKILL.md file is still in the repository.
Best practices for Snowpark Python (DataFrames, UDFs, UDTFs, stored procedures) and dbt with the dbt-snowflake adapter. Use when writing server-side Snowpark pipelines, registering UDFs or stored procedures, choosing dbt materializations, configuring incremental models, or setting up sources and tests for a Snowflake-backed dbt project.
Install
npx vskill@latest install mindrally/skills/snowflake-snowpark-dbtSKILL.md
Snowflake Snowpark Python & dbt
This skill covers building production data transformation pipelines with Snowpark Python (Snowflake's server-side Python API) and with dbt using the dbt-snowflake adapter.
Workflow for a Snowpark or dbt Transformation
- Snowpark: open a session — Build a
Sessionfrom environment-scoped credentials, specifying role, warehouse, database, and schema explicitly. - Snowpark: express transforms with the DataFrame API — Prefer
.filter(),.select(),.group_by().agg(), and.join()over raw SQL strings for reusable pipeline code; DataFrames are lazily evaluated and only execute on.collect()/.show()/a write action. - Snowpark: push compute server-side — Use scalar UDFs for row-wise logic, vectorized (pandas) UDFs for ML inference, UDTFs when one input row produces multiple output rows, and stored procedures for multi-step server-side orchestration.
- dbt: model in layers — Staging models (
stg_*) rename and type-cast; mart models express business logic on top of staging. - dbt: choose a materialization —
viewfor cheap logic,tableonly when reads are frequent,incrementalfor large fact tables,dynamic_tablefor near-real-time freshness needs. - dbt: define sources and tests — Declare sources in
_sources.ymlwith freshness thresholds; addunique/not_nulltests on key columns. - dbt: run selectively — Use
dbt run --select model+(model and downstream) or+model(model and upstream) instead of full-project runs during iteration. - dbt: build and validate — Run
dbt build(run + test in dependency order) before merging, anddbt docs generateto keep documentation current.
Snowpark Python
Snowpark runs Python server-side inside a Snowflake warehouse — data never leaves Snowflake. Core abstractions: Session, DataFrame, UDF, UDTF, UDAF, and Stored Procedure.
Session
Never hardcode credentials — always read them from environment variables or a secrets manager.
DataFrame API
DataFrames are lazily evaluated: Snowpark builds a query plan and only executes it on collect()/show() or a write action.
Key operations: .filter(), .select(), .group_by().agg(), .join(), .sort(), .with_column(), .drop(), .distinct(), .limit(), .union_all(), .flatten(), .write.save_as_table().
Scalar UDFs
Vectorized UDFs
Vectorized (pandas) UDFs are 10-100x faster than scalar UDFs for ML inference because they batch rows instead of invoking Python per row.
UDTFs (return multiple rows per input)
Stored procedures
Packages and file access
- Add third-party packages with
session.add_packages("pandas", "scikit-learn==1.3.0", "xgboost")— pin versions for production UDFs and stored procedures. - Attach static files (e.g., a pickled model) with
session.add_import("@my_stage/model.pkl"). - For pandas-on-Snowflake with no data movement to the client, use
modin.pandaswith the Snowpark plugin:import modin.pandas as pd; import snowflake.snowpark.modin.plugin; df = pd.read_snowflake("my_table").
dbt with the Snowflake Adapter
Install with pip install dbt-snowflake.
profiles.yml
Never commit real credentials into profiles.yml — always source secrets from env_var().
Materializations
Available materializations: view, table, incremental, ephemeral, dynamic_table. Default to view for cheap logic; reserve table for models read frequently enough to justify storage cost; use incremental for large fact tables and dynamic_table when near-real-time freshness matters.
Dynamic Tables in dbt
Incremental models
Always guard {{ this }} with {% if is_incremental() %} — referencing it unconditionally breaks the first (full) run, when the target table doesn't exist yet.
Snowflake-specific configs
cluster_by=['col1', 'col2']— clustering, large tables only (generally >1TB).transient=true— no Fail-safe, lower storage cost; use for staging models.query_tag='finance_daily'— workload attribution for cost tracking.copy_grants=true— preserve access grants across aCREATE OR REPLACE.snowflake_warehouse='lg_wh'— per-model warehouse override for heavy transforms.secure=true— secure views, for models exposing sensitive columns.
Sources with freshness checks
Testing
Key commands
dbt run,dbt test,dbt build(run + test in dependency order),dbt compiledbt run --select my_model+— model and everything downstreamdbt run --select +my_model— model and everything upstreamdbt source freshness— check source staleness against configured thresholdsdbt docs generate && dbt docs serve— build and preview documentation
Custom schema naming
Best Practices
- Prefer vectorized (pandas) UDFs over scalar UDFs for ML inference.
- Pin package versions in production UDFs and stored procedures.
- Use the Snowpark DataFrame API over raw SQL strings in reusable Python pipelines.
- Use staging models (
stg_*) to rename and type-cast; keep business logic in mart models. - Use
incrementalmaterialization for fact tables anddynamic_tablefor near-real-time needs. - Set
on_schema_change='sync_all_columns'on incremental models to handle upstream schema drift safely. - Use
copy_grants=trueto avoid permission churn on rebuild, and tag models for selective execution. - Use separate warehouses for dbt runs versus interactive analyst queries.
Anti-Patterns
- Do not
.collect()large Snowpark DataFrames to the client — keep processing server-side. - Do not use Python loops over rows in Snowpark — use DataFrame operations or vectorized UDFs.
- Do not reference
{{ this }}in an incremental model without an{% if is_incremental() %}guard. - Do not set
cluster_byon small tables (under roughly 1TB) — the overhead outweighs the benefit. - Do not default every model to
materialized='table'— views are free until queried. - Do not hardcode database/schema names in dbt models — use
{{ ref() }}and{{ source() }}.
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingsnowflake-snowpark-dbt/SKILL.md
Popularity
- Repository stars
- 260
- Repository forks
- 39
- 7-day trend score
- 28
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/mindrally/skills/snowflake-snowpark-dbt)