Snowpark Python
Runtime Contexts
| Context |
Session |
Run / debug |
Project setup |
Workspaces .py file (Snowsight) |
get_active_session() — see references/snowpark-authoring.md |
python_file_action via python-files-in-workspaces |
Single .py on the notebook kernel — no uv init, no snow init |
| CLI / local project |
Session.builder.config("connection_name", ...) — see references/snowpark-authoring.md |
uv run |
uv init, snow init, pyproject.toml as below |
When both python-files-in-workspaces and this skill apply, use python-files-in-workspaces
for file/kernel tooling and this skill for Snowpark semantics.
Project Structure
project/
├── src/
│ ├── __init__.py
│ ├── pipeline.py # Main pipeline code
│ └── udf_def.py # UDF definitions
├── tests/
│ ├── __init__.py
│ ├── conftest.py # Shared fixtures
│ ├── test_pipeline.py # Pipeline tests
│ └── data/
│ ├── input_sample.csv # Test input data
│ └── expected_output.csv
├── configs.sql # DDLs and permission grants
└── pyproject.toml
Prerequisites
CLI/local projects only — skip this section for Workspaces .py files (see Runtime
Contexts).
Install uv
Check if uv is installed by running uv --version. If it's not installed, prompt the user to install it using one of these methods:
curl -LsSf https://astral.sh/uv/install.sh | sh (recommended)
brew install uv (macOS)
pip install uv
Create a Python Project
Use uv init to create a Python project if the folder is empty.
Create a Python Interpreter
Use uv venv --python 3.13 to create Python environment.
Install Python Packages
Use uv add to add project dependency packages.
Use uv pip install to install Python packages for development only.
Primary Operations
These are the common operations users perform regularly. Route here confidently for any general Snowpark request.
Plan the data pipeline
Plan the code in steps and explain to the user the plan. The plan may have these components depending the user's question but not limited to:
- Load data from data sources.
- Transform data. If this step is complex, break it down so it's easier for the user to understand.
- Save the data to the destination table or stage location.
Write Code
Use Snowpark Python Client to write code according to the above plan.
Run and debug
- Workspaces
.py: Run via python_file_action following python-files-in-workspaces.
Iterate until get_results shows runStatus: "success".
- CLI/local: Run using
uv to try and fix the problems. Iterate until the problem is fixed.
If you find there are permission or other configuration problems, fix them and put the SQL statement in configs.sql.
Deploy Code
Deploy stored procedures directly or as a snow snowpark CLI project. For more details, read references/snowpark-deployment.md.
Data Flow Detection
If the user describes a data workflow, route to Primary tier:
Common patterns:
- Write code: "I need to build data pipeline using Snowpark Python Client" → Write Snowpark Code
- Run and debug: "Run the code", "Fix the error", "Debug my pipeline" → Run and debug code
- Deploy code: "Deploy my Python as stored procedure", "Deploy my project using snow snowpark CLI" → Deployment workflow
Primary Routing Table
| User Language |
Operation |
Reference |
| Write code, build pipeline, load data, ingest data, transform data, Snowpark basics, ETL, DataFrame, CSV, Parquet, JSON, stage, join, aggregate, window function, UDF, UDTF, UDAF, vectorized UDF, DBAPI, JDBC, external database, pull data |
Write Snowpark Code |
references/snowpark-authoring.md |
| Deploy Python, Python stored procedure, Python UDF, register sproc, productionize Python, snow snowpark, snow init, generate project, snowflake.yml, build and deploy |
Deployment |
references/snowpark-deployment.md |
| Add logging to UDF, add tracing to procedure, profile Python code, instrument Snowpark code, slow UDF, slow procedure, snowflake-telemetry-python, Python profiler, ACTIVE_PYTHON_PROFILER |
Observability |
references/snowpark-observability.md |
⚠️ MANDATORY — If the task involves writing, building, or transforming data with Snowpark Python, you MUST read references/snowpark-authoring.md BEFORE writing any code. It contains critical Snowflake-specific behaviors that differ from standard Python/Pandas (NULL handling, division semantics, date functions, data loading). Skipping this reference will produce subtly broken code.
⚠️ MANDATORY — If the task involves deploying Snowpark Python code, read references/snowpark-deployment.md first.
⚠️ MANDATORY — If the task involves instrumenting Python code (logging, tracing) or profiling UDFs/procedures, read references/snowpark-observability.md first. For Event Table setup, alerts, or notifications, use the dedicated event-table, alert, or notification skills instead.
Secondary Operations
Route here when the user language contains explicit problems or operational indicators. These operations may become complex.
Only perform these when user explicitly asks.
Create Test Data
Write a Python program to generate the test data and run it only if the user asks.
Put the data into the folder tests/data.
Create Test Code
Use pytest to write the test code. Put the test code in folder tests.
Secondary Routing Table
| Explicit Indicators |
Operation |
Reference |
| Create test data, generate sample data, mock data, test fixtures |
Create Test Data |
Not yet supported |
| Write tests, create test code, unit tests, test my code |
Create Test Code |
Not yet supported |
| Add logging, add tracing, profile, instrument, slow UDF, slow procedure, snowflake-telemetry-python, Python profiler |
Observability |
references/snowpark-observability.md |
| Error, failing, debug, not working, fix, troubleshoot, why is it failing |
Troubleshooting |
Not yet supported |
Compound Requests
If the user describes multiple operations:
- Create a todo list capturing all requested operations
- Ask the user to confirm the order:
"I've identified these tasks: [list]. What order would you like me to tackle them?"
- Execute in confirmed order, completing each before moving to the next
- Note: Some operations have natural dependencies (e.g., ingest before transform before deploy)
Typical Customer Journey:
Write Code → Deploy → Monitor → Troubleshoot (if needed)
Typical Observability Journey:
- Setup: Create Event Table, configure account default
- Instrument: Add logging/tracing to Python code
- Deploy & Enable: Deploy code, set LOG_LEVEL
- Alert: Set up notifications for errors/warnings
- Debug: Query Event Table to understand failures
- Profile (if slow): Enable profiler, find hotspots
- Optimize: Fix code based on profiler output
All steps are covered in references/snowpark-observability.md.
Reference Index
Core Operations (Primary)
| Reference |
Purpose |
references/snowpark-authoring.md |
Pipeline authoring: session setup, loading data, transformations, saving results, UDF/UDTF/UDAF, performance, local testing |
references/snowpark-deployment.md |
Deploy Python code as Snowflake stored procedures or UDFs |
references/snowpark-observability.md |
Python instrumentation (logging, tracing) and profiling for Snowpark UDFs and stored procedures |
Operational (Secondary)
| Reference |
Purpose |
| Write Tests |
Write tests with pytest (only when user asks) — Not yet supported |
| Troubleshooting |
Debug errors, diagnose failures, fix issues — Not yet supported |
Stopping Points Summary
All references follow this philosophy: NO changes without explicit user approval.
- READ-ONLY queries: Can run freely (diagnostics, monitoring, telemetry queries)
- ANY mutation: Requires stopping point and user approval
See individual references for specific stopping points.
1---2name: snowpark-python3description: "**[REQUIRED]** Use for **ALL** requests involving Snowpark Python — writing pipelines, transforming data, loading files, deploying stored procedures/UDFs, OR observability. MUST invoke this skill even for seemingly simple tasks because Snowflake DataFrame semantics differ from Pandas in ways that silently produce wrong results (NULL handling, division by zero, GREATEST, datediff, type casting). Always load this skill BEFORE writing any Snowpark code. Triggers: Snowpark, Python, DataFrame, pipeline, ETL, ingest, transform, load data, CSV, Parquet, JSON, XML, join, aggregate, window function, UDF, UDTF, UDAF, Stored Procedure, deploy, snow snowpark CLI, DBAPI, JDBC, external database, pull data, event table, logging, tracing, trace events, profiler, debug UDF, debug procedure, observability, telemetry, slow procedure, alert on error, monitor."4metadata:5 source: https://skillmd.com/skills/s-14-h/snowpark-python6---78# Snowpark Python910## Runtime Contexts1112| Context | Session | Run / debug | Project setup |13|---|---|---|---|14| **Workspaces `.py` file** (Snowsight) | `get_active_session()` — see `references/snowpark-authoring.md` | `python_file_action` via `python-files-in-workspaces` | Single `.py` on the notebook kernel — **no** `uv init`, **no** `snow init` |15| **CLI / local project** | `Session.builder.config("connection_name", ...)` — see `references/snowpark-authoring.md` | `uv run` | `uv init`, `snow init`, `pyproject.toml` as below |1617When both `python-files-in-workspaces` and this skill apply, use `python-files-in-workspaces`18for file/kernel tooling and this skill for Snowpark semantics.1920---2122## Project Structure2324```25project/26├── src/27│ ├── __init__.py28│ ├── pipeline.py # Main pipeline code29│ └── udf_def.py # UDF definitions30├── tests/31│ ├── __init__.py32│ ├── conftest.py # Shared fixtures33│ ├── test_pipeline.py # Pipeline tests34│ └── data/35│ ├── input_sample.csv # Test input data36│ └── expected_output.csv37├── configs.sql # DDLs and permission grants38└── pyproject.toml39```4041---4243## Prerequisites4445**CLI/local projects only** — skip this section for Workspaces `.py` files (see Runtime46Contexts).4748### Install `uv`49**Check if `uv` is installed** by running `uv --version`. If it's not installed, prompt the user to install it using one of these methods:50 - `curl -LsSf https://astral.sh/uv/install.sh | sh` (recommended)51 - `brew install uv` (macOS)52 - `pip install uv`5354### Create a Python Project55Use `uv init` to create a Python project if the folder is empty.5657### Create a Python Interpreter58Use `uv venv --python 3.13` to create Python environment.5960### Install Python Packages61Use `uv add` to add project dependency packages.62Use `uv pip install` to install Python packages for development only.6364---6566## Primary Operations6768These are the common operations users perform regularly. Route here confidently for any general Snowpark request.6970### Plan the data pipeline71Plan the code in steps and explain to the user the plan. The plan may have these components depending the user's question but not limited to:721. Load data from data sources.732. Transform data. If this step is complex, break it down so it's easier for the user to understand.743. Save the data to the destination table or stage location.7576### Write Code77Use Snowpark Python Client to write code according to the above plan.7879### Run and debug8081- **Workspaces `.py`:** Run via `python_file_action` following `python-files-in-workspaces`.82 Iterate until `get_results` shows `runStatus: "success"`.83- **CLI/local:** Run using `uv` to try and fix the problems. Iterate until the problem is fixed.8485If you find there are permission or other configuration problems, fix them and put the SQL statement in configs.sql.8687### Deploy Code8889Deploy stored procedures directly or as a snow snowpark CLI project. For more details, read `references/snowpark-deployment.md`.9091### Data Flow Detection9293If the user describes a data workflow, route to Primary tier:9495**Common patterns:**96- **Write code:** "I need to build data pipeline using Snowpark Python Client" → Write Snowpark Code97- **Run and debug:** "Run the code", "Fix the error", "Debug my pipeline" → Run and debug code98- **Deploy code:** "Deploy my Python as stored procedure", "Deploy my project using snow snowpark CLI" → Deployment workflow99100### Primary Routing Table101102| User Language | Operation | Reference |103|---------------|-----------|-----------|104| Write code, build pipeline, load data, ingest data, transform data, Snowpark basics, ETL, DataFrame, CSV, Parquet, JSON, stage, join, aggregate, window function, UDF, UDTF, UDAF, vectorized UDF, DBAPI, JDBC, external database, pull data | Write Snowpark Code | `references/snowpark-authoring.md` |105| Deploy Python, Python stored procedure, Python UDF, register sproc, productionize Python, snow snowpark, snow init, generate project, snowflake.yml, build and deploy | Deployment | `references/snowpark-deployment.md` |106| Add logging to UDF, add tracing to procedure, profile Python code, instrument Snowpark code, slow UDF, slow procedure, snowflake-telemetry-python, Python profiler, ACTIVE_PYTHON_PROFILER | Observability | `references/snowpark-observability.md` |107108**⚠️ MANDATORY** — If the task involves writing, building, or transforming data with Snowpark Python, you MUST read `references/snowpark-authoring.md` BEFORE writing any code. It contains critical Snowflake-specific behaviors that differ from standard Python/Pandas (NULL handling, division semantics, date functions, data loading). Skipping this reference will produce subtly broken code.109110**⚠️ MANDATORY** — If the task involves deploying Snowpark Python code, read `references/snowpark-deployment.md` first.111112**⚠️ MANDATORY** — If the task involves instrumenting Python code (logging, tracing) or profiling UDFs/procedures, read `references/snowpark-observability.md` first. For Event Table setup, alerts, or notifications, use the dedicated `event-table`, `alert`, or `notification` skills instead.113---114115## Secondary Operations116117Route here when the user language contains explicit problems or operational indicators. These operations may become complex.118119**Only perform these when user explicitly asks.**120121### Create Test Data122123Write a Python program to generate the test data and run it only if the user asks.124Put the data into the folder `tests/data`.125126### Create Test Code127128Use `pytest` to write the test code. Put the test code in folder `tests`.129130### Secondary Routing Table131132| Explicit Indicators | Operation | Reference |133|---------------------|-----------|-----------|134| Create test data, generate sample data, mock data, test fixtures | Create Test Data | Not yet supported |135| Write tests, create test code, unit tests, test my code | Create Test Code | Not yet supported |136| Add logging, add tracing, profile, instrument, slow UDF, slow procedure, snowflake-telemetry-python, Python profiler | Observability | `references/snowpark-observability.md` |137| Error, failing, debug, not working, fix, troubleshoot, why is it failing | Troubleshooting | Not yet supported |138139---140141## Compound Requests142143If the user describes multiple operations:1441451. Create a todo list capturing all requested operations1462. Ask the user to confirm the order:147 > "I've identified these tasks: [list]. What order would you like me to tackle them?"1483. Execute in confirmed order, completing each before moving to the next1494. Note: Some operations have natural dependencies (e.g., ingest before transform before deploy)150151**Typical Customer Journey:**152```153Write Code → Deploy → Monitor → Troubleshoot (if needed)154```155156**Typical Observability Journey:**1571581. **Setup**: Create Event Table, configure account default1592. **Instrument**: Add logging/tracing to Python code1603. **Deploy & Enable**: Deploy code, set LOG_LEVEL1614. **Alert**: Set up notifications for errors/warnings1625. **Debug**: Query Event Table to understand failures1636. **Profile** (if slow): Enable profiler, find hotspots1647. **Optimize**: Fix code based on profiler output165166All steps are covered in `references/snowpark-observability.md`.167168---169170## Reference Index171172### Core Operations (Primary)173174| Reference | Purpose |175|-----------|---------|176| `references/snowpark-authoring.md` | Pipeline authoring: session setup, loading data, transformations, saving results, UDF/UDTF/UDAF, performance, local testing |177| `references/snowpark-deployment.md` | Deploy Python code as Snowflake stored procedures or UDFs |178| `references/snowpark-observability.md` | Python instrumentation (logging, tracing) and profiling for Snowpark UDFs and stored procedures |179180### Operational (Secondary)181182| Reference | Purpose |183|-----------|---------|184| Write Tests | Write tests with pytest (only when user asks) — Not yet supported |185| Troubleshooting | Debug errors, diagnose failures, fix issues — Not yet supported |186187---188189## Stopping Points Summary190191All references follow this philosophy: **NO changes without explicit user approval.**192193- **READ-ONLY queries**: Can run freely (diagnostics, monitoring, telemetry queries)194- **ANY mutation**: Requires stopping point and user approval195196See individual references for specific stopping points.