Snowflake

Snowflake Notebooks for Analytics and Sharing: SQL/Python, Snowpark, Git

2026-03-26
更新: 2026-03-27
NicheeLab Editorial Team

Snowflake Notebooks is a managed environment inside Snowsight for interactive data analysis where you switch between SQL, Python, and Markdown on a per-cell basis. It brings together Snowpark DataFrame integration, built-in visualization, Git-based version control, and team collaboration, all within Snowflake's security model.

Notebooks Architecture

Snowflake Notebooks runs on the following components:

  • Front end: The notebook editor inside Snowsight (web UI). You add, run, and visualize cells right in the browser.
  • SQL runtime: SQL cells run on the warehouse you specify, using the same execution engine as regular Snowflake queries.
  • Python runtime: Python cells run on Snowpark's server-side runtime, backed by either a warehouse or an SPCS compute pool.
  • Storage: The notebook itself is stored as an object in a Snowflake schema. Data never leaves Snowflake.

Creating a Notebook and Basic Operations

You can create a notebook from the Snowsight UI or with SQL.

-- SQLでNotebookを作成
CREATE OR REPLACE NOTEBOOK analytics.notebooks.monthly_report
  FROM '@analytics.notebooks.nb_stage'
  MAIN_FILE = 'monthly_report.ipynb'
  QUERY_WAREHOUSE = analytics_wh
  COMMENT = '月次レポート分析ノートブック';

-- Notebookの一覧確認
SHOW NOTEBOOKS IN SCHEMA analytics.notebooks;

-- Notebookの権限付与
GRANT USAGE ON NOTEBOOK analytics.notebooks.monthly_report
  TO ROLE analyst_role;

Running SQL Cells

SQL cells let you run regular Snowflake SQL as-is. Results are shown as a table and can be switched to a chart view.

-- SQLセルの例: 売上サマリ
SELECT
  DATE_TRUNC('MONTH', order_date) AS order_month,
  product_category,
  COUNT(*) AS order_count,
  SUM(amount) AS total_revenue,
  AVG(amount) AS avg_order_value
FROM sales.orders
WHERE order_date >= '2025-01-01'
GROUP BY order_month, product_category
ORDER BY order_month, total_revenue DESC;

Working with Python Cells

Python cells let you process data with Snowpark DataFrames, and analyze or visualize using libraries like pandas, matplotlib, or plotly. There's also a built-in mechanism to reference SQL cell results from Python cells.

# Pythonセルの例: Snowpark DataFrameによる集計
from snowflake.snowpark.context import get_active_session
from snowflake.snowpark.functions import col, sum as sf_sum, count

session = get_active_session()

orders_df = session.table("sales.orders")

monthly_summary = (
    orders_df
    .filter(col("order_date") >= "2025-01-01")
    .group_by("product_category")
    .agg(
        count("*").alias("order_count"),
        sf_sum("amount").alias("total_revenue")
    )
    .sort(col("total_revenue").desc())
)

monthly_summary.show()

Bridging SQL and Python Cells

SQL cell results are accessible by the cell's name, and you can reference them from a Python cell using that name.

# cell_name_of_sql_cell がSQLセルの名前の場合:
# SQLの結果をSnowpark DataFrameとして取得
df = cell_name_of_sql_cell.to_df()

# SQLの結果をpandas DataFrameとして取得
pdf = cell_name_of_sql_cell.to_pandas()

# pandasで追加分析
print(f"行数: {len(pdf)}")
print(pdf.describe())

# matplotlibで可視化
import matplotlib.pyplot as plt

pdf.plot(kind='bar', x='PRODUCT_CATEGORY', y='TOTAL_REVENUE')
plt.title('カテゴリ別売上')
plt.tight_layout()
plt.show()

Built-in Visualization

SQL cell results can be visualized with Snowsight's built-in chart features in addition to the table view.

  • Bar / line charts: Time-series trends and category comparisons
  • Scatter plots: Correlation between two variables
  • Heatmaps: Distribution of multi-dimensional data
  • Area charts: Changes in composition over time

Python cells can also use libraries such as matplotlib, plotly, and Altair for more advanced custom visualizations.

# Pythonセルでのplotlyによるインタラクティブ可視化
import plotly.express as px

pdf = cell_monthly_data.to_pandas()

fig = px.line(
    pdf,
    x='ORDER_MONTH',
    y='TOTAL_REVENUE',
    color='PRODUCT_CATEGORY',
    title='月次売上推移(カテゴリ別)'
)
fig.show()

Git Integration

Snowflake Notebooks supports Git repository integration, enabling notebook version control and team-based development.

-- Git Repository Integrationの作成
CREATE OR REPLACE GIT REPOSITORY analytics.notebooks.ml_repo
  API_INTEGRATION = github_api_integration
  GIT_CREDENTIALS = github_secret
  ORIGIN = 'https://github.com/myorg/ml-notebooks.git';

-- Gitリポジトリからノートブックをフェッチ
ALTER GIT REPOSITORY analytics.notebooks.ml_repo FETCH;

-- リポジトリ内のファイル一覧
SHOW GIT BRANCHES IN analytics.notebooks.ml_repo;
ls @analytics.notebooks.ml_repo/branches/main/;

-- Gitリポジトリからノートブックを作成
CREATE OR REPLACE NOTEBOOK analytics.notebooks.feature_engineering
  FROM '@analytics.notebooks.ml_repo/branches/main/'
  MAIN_FILE = 'feature_engineering.ipynb'
  QUERY_WAREHOUSE = ml_wh;

Collaboration and Access Control

Notebook permissions are managed by Snowflake's RBAC. Multiple users can edit the same notebook, with changes synchronized in real time.

-- アナリストロールにノートブックの使用権限を付与
GRANT USAGE ON NOTEBOOK analytics.notebooks.monthly_report
  TO ROLE analyst_role;

-- データサイエンティストロールにノートブックの所有権を付与
GRANT OWNERSHIP ON NOTEBOOK analytics.notebooks.ml_experiment
  TO ROLE data_scientist_role;

-- ウェアハウスの使用権限(ノートブック実行に必要)
GRANT USAGE ON WAREHOUSE analytics_wh
  TO ROLE analyst_role;

Package Management

Python cells can add packages from Snowflake's Anaconda channel. You can search for and add packages directly from the notebook UI.

# ノートブック内でのパッケージ追加(Pythonセル)
# Snowsightの「Packages」パネルからGUIで追加するか、以下のようにセッションで追加
session.add_packages('pandas', 'scikit-learn==1.4.0', 'plotly')

# requirements.txtからの一括追加
# session.add_requirements('requirements.txt')

Scheduling Notebook Runs

By scheduling notebooks as tasks, you can automate periodic report generation and model retraining.

-- ノートブックをスケジュール実行するタスク
CREATE OR REPLACE TASK run_monthly_report
  WAREHOUSE = analytics_wh
  SCHEDULE = 'USING CRON 0 6 1 * * Asia/Tokyo'
AS
  EXECUTE NOTEBOOK analytics.notebooks.monthly_report;

ALTER TASK run_monthly_report RESUME;

Security and Governance

  • No data exfiltration: Analytics data stays inside Snowflake, preventing downloads to the local machine.
  • RBAC integration: Notebook execution results are filtered based on the user's role permissions.
  • Masking policy enforcement: Tables with Dynamic Data Masking are also displayed with masks inside notebooks.
  • Audit logs: Notebook execution history is recorded in ACCOUNT_USAGE.QUERY_HISTORY.

What the Exam Asks About

  • Notebooks run inside Snowsight, and data never leaves Snowflake.
  • You can switch between SQL / Python / Markdown on a per-cell basis.
  • SQL cell results can be received as a DataFrame in a Python cell.
  • Git integration supports version control and team-based development.
  • Running a notebook requires USAGE permission on the warehouse.
  • Snowflake's RBAC, masking policies, and governance apply directly.

Check with a Practice Question

SnowPro

問題 1

A data scientist wants to analyze data in Snowflake Notebooks, extracting data with SQL and training a model with scikit-learn in Python. Which sequence of steps is correct?

  1. Extract the data in a SQL cell, download a CSV to the local machine, then train the model in Jupyter.
  2. Extract the data in a SQL cell, retrieve the cell's result in a Python cell with to_pandas(), and train the model with scikit-learn.
  3. Manually establish a JDBC connection in a Python cell, fetch the data with fetchall(), and train the model.
  4. SQL and Python cells can't be used together in the same notebook, so run them in separate notebooks.

正解: B

In Snowflake Notebooks, you can access a SQL cell's result by name and convert it to a pandas DataFrame with to_pandas() for use in a Python cell. Data stays inside Snowflake, so there's no need to download a CSV or set up a JDBC connection manually. Mixing SQL and Python in the same notebook is fully supported.

Frequently Asked Questions

How do Snowflake Notebooks differ from Jupyter Notebooks?

Snowflake Notebooks is a managed notebook environment that runs inside the Snowsight UI. Like Jupyter, it lets you run SQL/Python cell by cell, but the key differences are that data never leaves Snowflake and Snowflake's authentication, RBAC, and governance apply directly. The compute runs on Snowflake warehouses or Snowpark Container Services, so you don't need to install Python or libraries on your local machine.

Can you mix Python and SQL in Notebooks?

Yes. You can switch between SQL / Python / Markdown on a per-cell basis. A Python cell can receive a SQL cell's results as a Snowpark DataFrame or pandas DataFrame, so an end-to-end workflow like extract with SQL → train an ML model in Python → write results back with SQL can all live in a single notebook.

Does Notebooks support Git integration?

Yes. Snowflake Notebooks supports integration with Git repositories. From Snowsight you can connect a Git repository (GitHub / GitLab / Bitbucket, etc.) to version-control notebook files, switch branches, commit, and pull. With CI/CD pipeline integration, you can automate deploying notebook changes to production.

Check what you learned with practice questions

Practice with certification-focused question sets

無料で問題を解いてみる
Author

NicheeLab Editorial Team

NicheeLab editorial team focused on data engineering and cloud certification learning. Content is structured around practical study needs and official exam domains.


Related articles
Snowflake

Snowflake Certifications: All 11 Exams Explained (2026)

Every SnowPro certification — Associate, Core, Specialty, Ad...

Snowflake

Snowflake Exam Difficulty Ranking: All 11 Certs Compared (2026)

All 11 SnowPro exams ranked by difficulty with study-time es...

Snowflake

Snowflake Study Guide: Fastest Pass Route by Exam (2026)

How to pass SnowPro certifications efficiently — official ma...

Snowflake

SnowPro Core (COF-C03): Complete Exam Guide (2026)

Pass the SnowPro Core exam — six domains, scope, sample ques...

Snowflake

SnowPro Associate Platform (SOL-C01): Complete Guide (2026)

The entry-level SnowPro Associate exam — scope, weighting, s...

Browse all Snowflake articles (103)
© 2026 NicheeLab All rights reserved.