About Snowflake Notebooks¶
Snowflake Notebooks offer an interactive, cell-based programming environment for Python and SQL. With a Snowflake Notebook, you can perform exploratory data analysis, experiment with feature engineering for machine learning, and perform other data science tasks within Snowflake.
You can write and execute code, visualize results, and tell the story of your analysis all in one place.
Explore and experiment with data already in Snowflake, or upload new data to Snowflake from local files, external cloud storage, or datasets from the Snowflake Marketplace.
Write SQL or Python code and quickly compare results with cell-by-cell development and execution.
Interactively visualize your data using embedded Streamlit visualizations and other libraries like Altair, Matplotlib, or seaborn.
Contextualize results and make notes about different results with Markdown cells.
Keep your data fresh by relying on the default behavior to run a cell and all modified cells preceding it or debug your notebook by running it cell-by-cell.
Make use of the role-based access control and other data governance functionality available in Snowflake to allow other users with the same role to view and collaborate on the notebook.
Before you start writing Snowflake Notebooks, review the Considerations for Snowflake Notebooks.
To get started using Snowflake Notebooks, see Create and manage Snowflake Notebooks.
Considerations for Snowflake Notebooks¶
You must use Snowsight to access Snowflake Notebooks. Snowflake Notebooks are not based on the Jupyter kernel, but you can import
and export .ipynb
files. See Import a notebook and Export a notebook.
Account and deployment considerations for using Snowflake Notebooks¶
Ensure that *.snowflake.app
is on the allowlist in your network and can connect to Snowflake.
When this domain is on the allowlist, your apps can communicate with Snowflake servers without
any restrictions.
In addition, the following account considerations apply:
Your Snowflake account must be located in an Amazon Web Services (AWS) region.
Accounts in the following regions are not currently supported:
Microsoft Azure
Google Cloud Platform (GCP)
Virtual Private Snowflake (VPS)
US government regions that support FedRAMP
Using AWS PrivateLink or Azure Private Link is not supported.
The combined length of your account name and organization name must be less than 41 characters.
Your account name must be unique within your organization.
Considerations for setting up notebooks¶
When you create a notebook, you select a database and schema in which to store your notebook. The database and schema that you select cannot be changed, but you can reference objects in any database or schema that your role can access.
Your role must have, at a minimum, USAGE privileges on the database and schema that contain the notebook. See Privileges required to create or modify a notebook.
You also select a warehouse for your notebook. See Warehouse recommendations for running Snowflake Notebooks.
You cannot install packages using
pip
. Instead, use the web interface to select third-party packages listed in the Snowflake Anaconda channel.
Considerations for writing notebooks and adding cells¶
When writing SQL, you are limited to one SQL statement per cell. See Write SQL code in a notebook.
When referencing objects in SQL cells, you must use fully qualified object names, unless you are referencing object names in a specified database or schema. See Changing the session context for a notebook.
Notebook drafts are saved every three seconds, but using source control like Git to maintain notebook versions is not supported at this time.
When you use the st.map or st.pydeck_chart Streamlit commands, Mapbox provides the map tiles when rendering map content. Mapbox is a third-party application and is subject to Snowflake’s External Offerings Terms.
Some Streamlit elements are not supported:
-
The
page_title
andpage_icon
properties of the st.set_page_config command are not supported. Custom Components, including:
The following experimental features:
Unsafe HTML using
unsafe_allow_html=True
is not supported in st.markdown.Network access via the internet
Anchor links
Considerations for running notebooks¶
Notebooks run using caller’s rights. See Changing the session context for a notebook for additional considerations.
After you start running a cell, you can only stop or suspend the generated query if you refresh the page.
Scheduling notebooks is not supported at this time.
Notebook cell results are cached across sessions. Reopening a notebook displays past results from the last time you ran the notebook. The cached results are only visible for the same user that ran the notebook.
Changing the session context for a notebook¶
When you create a notebook, you define a role, warehouse, database, and schema to use in the notebook. When you run the notebook, it runs as that role, using the warehouse defined in the notebook, and in the context of the database and schema that contain the notebook.
If you want, you can change the session context of the notebook to use a different role, database and schema, and/or warehouse:
Specify a different role to use with the USE ROLE SQL command.
You can check the role in use by the notebook by calling the CURRENT_ROLE function.
If you change your role to one that does not have privileges to use the notebook warehouse, database, or schema, queries that require a warehouse or access to the notebook database or schema fail to run. However, you can still run queries that do not use the notebook warehouse, database, and schema.
Roles specified with the USE ROLE SQL command do not persist across notebook sessions.
If you specify a database or schema that the currently active role does not have privileges to access, queries using that database and schema fail to run.
If you run the SQL command USE SECONDARY ROLES to set secondary roles to ALL, the secondary roles associated with your user are used to generate the results of the notebook cells.
Specify a different warehouse using the SQL command USE WAREHOUSE.
You can check the warehouse in use for the notebook by calling the CURRENT_WAREHOUSE function.
Specify a different database or schema using USE DATABASE or USE SCHEMA SQL commands.
You can check the database in use for the notebook by calling the CURRENT_DATABASE function.
If you reference objects in the notebook database or the database specified in an earlier notebook cell, you can simplify your SQL statements to include only the schema and object that you want to reference, instead of the fully qualified path to the object.
Considerations for sharing notebooks¶
The role used to create the notebook owns the notebook.
Any user with that role, or whose role inherits that role, can edit and view the notebook.
To share and collaborate on a notebook with another user, that user must either have the owner role or be granted a role that inherits the owner role of the notebook.
You cannot share a notebook with other roles.
See Sharing notebooks.
Billing considerations for running Snowflake Notebooks¶
Running a Snowflake Notebook requires a virtual warehouse.
Similar to billing for a Streamlit app, a Snowflake Notebook uses a websocket connection to run queries. The virtual warehouse remains active while the websocket connection is active. The connection expires when you close your notebook or approximately 15 minutes after it is last used by a notebook, whichever is sooner. Each notebook has its own session.
See Warehouse recommendations for running Snowflake Notebooks.
Get started using notebooks by adding data¶
Before you get started using Snowflake Notebooks, add data to Snowflake.
You can add data to Snowflake in several ways:
Add data from a CSV file to a table using the web interface. See 웹 인터페이스를 사용하여 데이터 로드하기.
Add data from external cloud storage:
To load data from Amazon S3, see Amazon S3에서 대량 로드.
To load data from Google Cloud Storage, see Google Cloud Storage에서 대량 로드하기.
To load data from Microsoft Azure, see Microsoft Azure에서 대량 로드하기.
Add data in bulk programmatically. See 로컬 파일 시스템에서 대량 로드하기.
You can also add data in other ways. See 데이터 로딩 개요 for complete details.