Getting Started with Snowflake Notebooks
Authors: Sarah Narum, Elle Estwick, Stephen Lowery, Emma York
This repository covers how to get started with Snowflake Notebooks from 0 to a working set of notebooks, ready to deploy to your Snowflake account today!
Setup
We'll need to create a few resources to get ready for our Notebook and have some data to interact with. The next few steps will walk you through how to do that.
Role, Database, and Warehouse Creation
To get started, go ahead and create a new Worksheet in the Snowflake UI. We'll be creating a Role, Database, and Warehouse. We'll then grant our role the ability to use the database/warehouse, then grant that role to our user account. This gives us the access we need to do the next steps. This guide assumes that you have access to the sysadmin
and securityadmin
roles- if not, you can use roles within your account with similar permissions or reach out to your account administrator for assistance.
Copy the content of the setup script, paste it into your notebook, and review the commands/comments. Before executing the script, change the text YOUR_USER_HERE
to be your snowflake username.
Once you're satisfied with the commands in your worksheet, select the text and click the "Run" button. When the commands execute successfully you should be able to validate your newly created objects by running:
use role notebook_lab_role;
desc database notebook_lab_db;
You should see some basic information about the database we just created. Additionally, it should now appear in the object explorer pane on the left of the snowflake console
Note: If you're using a personal account or are otherwise cost-constrained, it's probably a good idea to set up a Resource Monitor before moving on. We've provided an example script here. This does require accountadmin
permissions- so you may have to reach out to your account admin to get it set up (if they don't have one already).
Load Data to a new table
We will be using Kaggle's Full IMDb Dataset - available to download here.
Navigate to 'Data' in the lefthand menu and select 'Add Data'. For this Lab we will be using the 'Load data into a Table' functionality to load data directly from a file into a table:
Select your warehouse in the upper right corner of the pop up and use the 'Browse' button to select your data file:
Select your target database and schema, choose 'Create new table' and give your new table a name. Click Next:
The next window will allow you to update data types, column names and decide what should happen if an error occurs. For this lab, leave the default setting on the left two options and update the 'DATA TYPE' for column 'averageRating' to FLOAT. Click 'Load':
Once your data has successfully loaded, simply click 'Done'!
Create Notebook
To create a new notebook, Navigate to the "Projects" section on the left pane and select the "Notebooks" tab. Click on the "+ Notebook" button in the top right:
In the resulting dialog, give the notebook a name (like Snowflake Lab
), a location (in our NOTEBOOK_LAB_DB
database) and select the NOTEBOOK_LAB_WH
as the warehouse. For the Python environment option, leave it on Run on warehouse
, then click "Create":
To make sure the notebook works, copy the following code into the first cell:
select min(releaseyear), max(releaseyear) from notebook_lab_db.public.imdb
You should see a response like:
We've successfully created a Snowflake Notebook!
Feb 26, 2025 12:30:00 AM
Comments