0
0
Snowflakecloud~30 mins

Why Snowpark brings code to the data in Snowflake - See It in Action

Choose your learning style9 modes available
Why Snowpark Brings Code to the Data
📖 Scenario: You work at a company that stores large amounts of data in Snowflake. You want to process this data efficiently without moving it around.
🎯 Goal: Build a simple Snowpark program that shows how to bring code to the data inside Snowflake, instead of moving data out for processing.
📋 What You'll Learn
Create a Snowpark session connected to Snowflake
Create a DataFrame from an existing table called sales_data
Define a simple transformation function using Snowpark
Apply the function to the DataFrame and collect results
💡 Why This Matters
🌍 Real World
Companies use Snowpark to run data processing close to where data lives in Snowflake. This reduces data movement, speeds up processing, and improves security.
💼 Career
Understanding Snowpark is valuable for data engineers and cloud architects who build scalable data pipelines and analytics solutions on Snowflake.
Progress0 / 4 steps
1
Create a Snowpark session
Write code to create a Snowpark session called session using the Session.builder.configs() method with a dictionary connection_parameters containing your Snowflake account details.
Snowflake
Need a hint?

Use Session.builder.configs(connection_parameters).create() to create the session.

2
Create a DataFrame from the sales_data table
Use the session.table() method to create a DataFrame called df from the existing table named sales_data.
Snowflake
Need a hint?

Use df = session.table("sales_data") to create the DataFrame.

3
Define a transformation function using Snowpark
Define a function called add_discount that takes a DataFrame df and returns a new DataFrame with a new column discounted_price calculated as price * 0.9.
Snowflake
Need a hint?

Use with_column to add the new column inside the function.

4
Apply the function and collect results
Call the add_discount function with df and assign the result to df_discounted. Then use df_discounted.collect() to fetch the results into a variable called results.
Snowflake
Need a hint?

Assign the function result to df_discounted and then call collect() to get results.