Connect Data in Snowflake
Connect your Snowflake notebook to tables and views in a Snowflake schema.
Prerequisites
Before you start, complete the steps in Install Kumo Engine in a Snowflake Notebook, including local working storage. If setup already created your connector, reuse it and run the access check below.
Choose a Source
The following table shows the connection to use for Snowflake tables and views in your notebook:
If you are running Python locally instead, use the local Python Snowflake connection.
Snowflake Tables and Views
The notebook role needs access to the query warehouse, database, schema, and source tables or views. Use the query warehouse that can read your data. This warehouse is separate from the compute pool running the notebook. Replace COMPUTE_WH, ANALYTICS, and PUBLIC with your warehouse, database, and schema:
from_spcs_env() reads the runtime account, host, and mounted OAuth token. Do not copy the token into the notebook. An active Snowpark session alone does not provide these credentials. If runtime credentials are missing, check that you are using the container notebook environment from setup.
Check Source Access
List the available tables, then inspect one of them. Replace ORDERS with a name from the listing, preserving its capitalization:
Expect the selected table’s column names. This check verifies discovery and schema access. The graph snapshot reads the data later. If the listing is empty or the expected table is missing, check the configured database and schema and the role’s source grants. If reading columns fails, confirm the exact table name and the role’s warehouse and source access.
Continue with Define Tables or the Snowflake notebook example.
How Access Works in a Snowflake Notebook
Kumo respects the notebook’s access control: it can only read the tables and views the notebook’s role can already access. Your data stays in your Snowflake account, and Kumo sends nothing outside it.
In a container notebook, connect with SnowflakeConnector.from_spcs_env():
- Kumo queries your query warehouse with the notebook’s access token, as the notebook’s role.
- Snowflake checks that role’s grants and records the query in its query history. Only permitted data comes back, and Kumo keeps it on the notebook’s compute while training.
- Kumo writes predictions and models to your Snowflake tables and Model Registry. Snowflake checks these writes as well.
For data outside Snowflake, use another Kumo connector with the credentials and network access the notebook needs.
Advanced Configuration
Select Another Source Schema
Create another connector with the same runtime helper and the target warehouse, database, and schema. The notebook role needs access to that location too. For example, replace REFERENCE_DATA with the schema you want to read:
Use the local Python guide’s password and key pair procedure only when deliberately connecting with a separate identity.
Prepare Prediction Outputs
Use a dedicated output schema for saved prediction tables. Have the schema owner create it first and grant the execution role USAGE on the database, schema, and query warehouse, plus CREATE TABLE and CREATE FILE FORMAT on the output schema. Kumo uploads local prediction files to a temporary stage and creates a temporary file format to infer the output table schema. This workflow does not require creating a named stage. Refer to Snowflake’s file format privileges.
Writing to an existing table requires INSERT, plus DELETE for overwrite. Reading the saved output also requires SELECT on that table. Source-read access alone is insufficient. In a scheduled job, grant these permissions to the job’s execution role.
Continue to Choose the Prediction Output Location.
Retain Predictions and Models
Use Snowflake tables for prediction outputs and Snowflake Model Registry for model retention. Source read grants do not authorize output writes. Notebook scratch paths are temporary working files, not Snowflake tables or stages.
Reuse the Connector After a Restart
After a kernel restart, rerun the import, working storage configuration, and connector cells from setup. Connectors are Python objects rather than entries in a persistent Kumo connector registry. If a source schema changes, obtain a new reference with connector.table("ORDERS") before inspecting its columns again.
Next Steps
Continue with one of the following topics: