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')
Invest now in Acorns!!! 🚀
Join Acorns and get your $5 bonus!
Acorns is a micro-investing app that automatically invests your "spare change" from daily purchases into diversified, expert-built portfolios of ETFs. It is designed for beginners, allowing you to start investing with as little as $5. The service automates saving and investing. Disclosure: I may receive a referral bonus.
Invest now!!! Get Free equity stock (US, UK only)!
Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.
The Robinhood app makes it easy to trade stocks, crypto and more.
Webull! Receive free stock by signing up using the link: Webull signup.
More Related questions...
