Database / Snowflake Interview Questions
What is Snowpark and how does it allow Python/Java/Scala code to run inside Snowflake?
Snowpark is Snowflake's developer framework that lets you write Python, Java, or Scala code that executes inside the Snowflake engine rather than pulling data to an external machine. The core abstraction is the Snowpark DataFrame, which works like Apache Spark or pandas DataFrames: you compose transformations lazily, and Snowflake compiles them into SQL and executes them on the Virtual Warehouse.
The primary benefit is that data never leaves Snowflake. Instead of pulling 100 GB to a Python server, applying transformations, and pushing results back, the transformation runs where the data lives — in Snowflake compute. This eliminates egress costs, reduces latency, and scales with warehouse size.
Deployment targets in Snowpark:
- Snowpark Stored Procedures — Python/Java/Scala logic callable via
CALL proc_name(), running on the caller's warehouse. - User-Defined Functions (UDFs) — scalar or tabular functions callable from any SQL query.
- User-Defined Aggregate Functions (UDAFs) — custom aggregations in Python/Java.
- Snowpark ML — train and deploy scikit-learn, XGBoost, LightGBM models entirely inside Snowflake.
- Snowpark Container Services — run arbitrary Docker containers within Snowflake's network for full-custom workloads.
# Python Snowpark: run a transformation inside Snowflake
from snowflake.snowpark import Session
session = Session.builder.configs(connection_params).create()
# Build a lazy DataFrame — nothing runs yet
df = session.table('raw_events')
df_clean = (
df.filter(df['event_type'] == 'purchase')
.select('user_id', 'amount', 'event_ts')
.group_by('user_id')
.agg({'amount': 'sum'})
)
# Action: push result into Snowflake -- runs as SQL on the warehouse
df_clean.write.save_as_table('user_purchase_summary', mode='overwrite')
More Related questions...