malloy
Googleが開発した新しいデータ言語Malloyを使って、分析しやすいモデルを作成したり、複雑なクエリを構築したり、VS Code拡張機能やノートブックでデータを探索したりする開発者を支援するSkill。
📜 元の英語説明(参考)
Expert guidance for Malloy, the experimental data language from Google that replaces SQL for analytics with a composable, reusable, and more readable syntax. Helps developers write Malloy models, build nested queries, and explore data with Malloy's VS Code extension and notebook interface.
🇯🇵 日本人クリエイター向け解説
Googleが開発した新しいデータ言語Malloyを使って、分析しやすいモデルを作成したり、複雑なクエリを構築したり、VS Code拡張機能やノートブックでデータを探索したりする開発者を支援するSkill。
※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。
下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o malloy.zip https://jpskill.com/download/15098.zip && unzip -o malloy.zip && rm malloy.zip
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/15098.zip -OutFile "$d\malloy.zip"; Expand-Archive "$d\malloy.zip" -DestinationPath $d -Force; ri "$d\malloy.zip"
完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。
💾 手動でダウンロードしたい(コマンドが難しい人向け)
- 1. 下の青いボタンを押して
malloy.zipをダウンロード - 2. ZIPファイルをダブルクリックで解凍 →
malloyフォルダができる - 3. そのフォルダを
C:\Users\あなたの名前\.claude\skills\(Win)または~/.claude/skills/(Mac)へ移動 - 4. Claude Code を再起動
⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。
🎯 このSkillでできること
下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。
📦 インストール方法 (3ステップ)
- 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
- 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
- 3. 展開してできたフォルダを、ホームフォルダの
.claude/skills/に置く- · macOS / Linux:
~/.claude/skills/ - · Windows:
%USERPROFILE%\.claude\skills\
- · macOS / Linux:
Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。
詳しい使い方ガイドを見る →- 最終更新
- 2026-05-18
- 取得日時
- 2026-05-18
- 同梱ファイル
- 1
📖 Skill本文(日本語訳)
※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。
Malloy — セマンティックデータ言語
概要
Malloy は Google が開発した実験的なデータ言語で、分析における SQL を、構成可能で再利用可能、かつより読みやすい構文に置き換えます。開発者は Malloy モデルの作成、ネストされたクエリの構築、Malloy の VS Code 拡張機能とノートブックインターフェースによるデータの探索に役立ちます。
手順
ソース定義
再利用可能なデータモデルを定義します。
// models/ecommerce.malloy — Ecommerce データモデル
source: orders is duckdb.table('orders.parquet') extend {
// ディメンション (グループ化する属性)
dimension:
order_date is created_at::date
order_month is created_at.month
order_year is created_at.year
is_high_value is amount > 100
order_size is pick
'small' when items_count < 3
'medium' when items_count < 10
'large'
// メジャー (集計)
measure:
order_count is count()
total_revenue is sum(amount)
avg_order_value is avg(amount)
unique_customers is count(distinct customer_id)
revenue_per_customer is total_revenue / unique_customers
// 再利用可能な名前付きクエリ (ビュー)
view: revenue_by_month is {
group_by: order_month
aggregate:
total_revenue
order_count
avg_order_value
order_by: order_month
}
view: top_customers is {
group_by: customer_id
aggregate:
total_revenue
order_count
order_by: total_revenue desc
limit: 20
}
view: daily_dashboard is {
group_by: order_date
aggregate:
total_revenue
order_count
unique_customers
avg_order_value
order_by: order_date desc
limit: 30
}
}
クエリ
構成可能で読みやすい分析クエリを作成します。
// queries/analysis.malloy — モデルを使用した分析クエリ
import "models/ecommerce.malloy"
// 単純な集計
run: orders -> {
aggregate:
total_revenue
order_count
avg_order_value
}
// フィルタを使用したグループ化
run: orders -> {
where: order_year = 2026
group_by: order_month
aggregate:
total_revenue
order_count
order_by: order_month
}
// ネストされたクエリ — 1つのクエリに複数のレベルの集計
run: orders -> {
group_by: order_size
aggregate:
total_revenue
order_count
avg_order_value
// ネスト: 各 order_size について、月ごとの内訳を表示
nest: monthly_trend is {
group_by: order_month
aggregate: total_revenue
order_by: order_month
}
// ネスト: 各 order_size について、上位顧客を表示
nest: top_customers is {
group_by: customer_id
aggregate: total_revenue, order_count
order_by: total_revenue desc
limit: 5
}
}
// パイプライン: 変換をチェーンする
run: orders
-> { where: status = 'completed' }
-> revenue_by_month // 名前付きビューの再利用
-> { where: total_revenue > 10000 } // 結果のフィルタ
結合とリレーションシップ
// models/full_model.malloy — 結合を使用した複数テーブルモデル
source: customers is duckdb.table('customers.parquet') extend {
dimension: signup_month is created_at.month
measure:
customer_count is count()
avg_lifetime_value is avg(lifetime_value)
}
source: products is duckdb.table('products.parquet') extend {
dimension: price_tier is pick
'budget' when price < 25
'mid-range' when price < 100
'premium'
measure: product_count is count()
}
source: order_items is duckdb.table('order_items.parquet') extend {
// 関連テーブルへの結合
join_one: orders on order_id = orders.id
join_one: products on product_id = products.id
join_one: customers is orders.customer_id = customers.id
measure:
total_quantity is sum(quantity)
item_revenue is sum(quantity * unit_price)
// 結合されたテーブル全体に対するクエリ
view: revenue_by_category is {
group_by: products.category
aggregate:
item_revenue
total_quantity
order_by: item_revenue desc
}
view: customer_product_matrix is {
group_by: customers.signup_month
aggregate: item_revenue
nest: by_category is {
group_by: products.category
aggregate: item_revenue
}
}
}
ノートブックと可視化
// Malloy ノートブック (.malloynb) または VS Code 拡張機能内
// Malloy は必要に応じて結果をチャートとして自動的にレンダリングします
// 棒グラフ — 単一のメジャーによるグループ化
run: orders -> {
group_by: status
aggregate: order_count
}
// # bar_chart
// 折れ線グラフ — 時系列
run: orders -> revenue_by_month
// # line_chart
// ダッシュボード — 1つのクエリからの複数の可視化
run: orders -> {
group_by: order_size
aggregate: total_revenue, order_count
nest: trend is {
group_by: order_month
aggregate: total_revenue
}
}
// # dashboard
DuckDB と BigQuery の接続
// 接続構成
// DuckDB (ローカルファイル)
connection: duckdb is duckdb [
parquet_path: "./data/"
]
// BigQuery
connection: bq is bigquery [
project_id: "my-gcp-project"
dataset: "analytics"
]
// モデルで BigQuery テーブルを使用する
source: events is bq.table('analytics.events') extend {
measure: event_count is count()
}
インストール
# VS Code 拡張機能 (推奨)
# VS Code Marketplace から "Malloy" をインストールします
# CLI
npm install -g @malloydata/malloy-cli
# Python パッケージ
pip install malloy
# Malloy ファイルを実行する
malloy run analysis.malloy
例
例 1: 既存のアプリケーションへの Malloy の統合
ユーザーリクエスト:
AI チャット機能のために、Next.js アプリに Malloy を追加したい。ストリーミング応答が必要です。
エージェントは SDK をインストールし、Malloy クライアントを初期化する API ルートを作成し、ストリーミングを設定し、適切なモデルを選択し、フロントエンドを接続してストリームを利用します。エラーケースを処理し、API キーの適切な環境変数管理を設定します。
例 2: クエリパフォーマンスの最適化
ユーザーリクエスト:
Malloy の呼び出しが遅く、コストがかかります。セットアップを最適化するのを手伝ってください。
エージェントは現在の実装を見直し、問題点 (間違ったモデルの選択、キャッシュの欠落) を特定します。
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開
Malloy — Semantic Data Language
Overview
Malloy, the experimental data language from Google that replaces SQL for analytics with a composable, reusable, and more readable syntax. Helps developers write Malloy models, build nested queries, and explore data with Malloy's VS Code extension and notebook interface.
Instructions
Source Definition
Define reusable data models:
// models/ecommerce.malloy — Ecommerce data model
source: orders is duckdb.table('orders.parquet') extend {
// Dimensions (attributes to group by)
dimension:
order_date is created_at::date
order_month is created_at.month
order_year is created_at.year
is_high_value is amount > 100
order_size is pick
'small' when items_count < 3
'medium' when items_count < 10
'large'
// Measures (aggregations)
measure:
order_count is count()
total_revenue is sum(amount)
avg_order_value is avg(amount)
unique_customers is count(distinct customer_id)
revenue_per_customer is total_revenue / unique_customers
// Reusable named queries (views)
view: revenue_by_month is {
group_by: order_month
aggregate:
total_revenue
order_count
avg_order_value
order_by: order_month
}
view: top_customers is {
group_by: customer_id
aggregate:
total_revenue
order_count
order_by: total_revenue desc
limit: 20
}
view: daily_dashboard is {
group_by: order_date
aggregate:
total_revenue
order_count
unique_customers
avg_order_value
order_by: order_date desc
limit: 30
}
}
Queries
Write composable, readable analytics queries:
// queries/analysis.malloy — Analytics queries using the model
import "models/ecommerce.malloy"
// Simple aggregation
run: orders -> {
aggregate:
total_revenue
order_count
avg_order_value
}
// Group by with filters
run: orders -> {
where: order_year = 2026
group_by: order_month
aggregate:
total_revenue
order_count
order_by: order_month
}
// Nested queries — multiple levels of aggregation in one query
run: orders -> {
group_by: order_size
aggregate:
total_revenue
order_count
avg_order_value
// Nested: for each order_size, show monthly breakdown
nest: monthly_trend is {
group_by: order_month
aggregate: total_revenue
order_by: order_month
}
// Nested: for each order_size, show top customers
nest: top_customers is {
group_by: customer_id
aggregate: total_revenue, order_count
order_by: total_revenue desc
limit: 5
}
}
// Pipeline: chain transformations
run: orders
-> { where: status = 'completed' }
-> revenue_by_month // Reuse named view
-> { where: total_revenue > 10000 } // Filter the result
Joins and Relationships
// models/full_model.malloy — Multi-table model with joins
source: customers is duckdb.table('customers.parquet') extend {
dimension: signup_month is created_at.month
measure:
customer_count is count()
avg_lifetime_value is avg(lifetime_value)
}
source: products is duckdb.table('products.parquet') extend {
dimension: price_tier is pick
'budget' when price < 25
'mid-range' when price < 100
'premium'
measure: product_count is count()
}
source: order_items is duckdb.table('order_items.parquet') extend {
// Join to related tables
join_one: orders on order_id = orders.id
join_one: products on product_id = products.id
join_one: customers is orders.customer_id = customers.id
measure:
total_quantity is sum(quantity)
item_revenue is sum(quantity * unit_price)
// Query across joined tables
view: revenue_by_category is {
group_by: products.category
aggregate:
item_revenue
total_quantity
order_by: item_revenue desc
}
view: customer_product_matrix is {
group_by: customers.signup_month
aggregate: item_revenue
nest: by_category is {
group_by: products.category
aggregate: item_revenue
}
}
}
Notebooks and Visualization
// In Malloy notebook (.malloynb) or VS Code extension
// Malloy auto-renders results as charts when appropriate
// Bar chart — group by with single measure
run: orders -> {
group_by: status
aggregate: order_count
}
// # bar_chart
// Line chart — time series
run: orders -> revenue_by_month
// # line_chart
// Dashboard — multiple visualizations from one query
run: orders -> {
group_by: order_size
aggregate: total_revenue, order_count
nest: trend is {
group_by: order_month
aggregate: total_revenue
}
}
// # dashboard
DuckDB and BigQuery Connections
// Connection configuration
// DuckDB (local files)
connection: duckdb is duckdb [
parquet_path: "./data/"
]
// BigQuery
connection: bq is bigquery [
project_id: "my-gcp-project"
dataset: "analytics"
]
// Use BigQuery tables in models
source: events is bq.table('analytics.events') extend {
measure: event_count is count()
}
Installation
# VS Code Extension (recommended)
# Install "Malloy" from VS Code Marketplace
# CLI
npm install -g @malloydata/malloy-cli
# Python package
pip install malloy
# Run a Malloy file
malloy run analysis.malloy
Examples
Example 1: Integrating Malloy into an existing application
User request:
Add Malloy to my Next.js app for the AI chat feature. I want streaming responses.
The agent installs the SDK, creates an API route that initializes the Malloy client, configures streaming, selects an appropriate model, and wires up the frontend to consume the stream. It handles error cases and sets up proper environment variable management for the API key.
Example 2: Optimizing queries performance
User request:
My Malloy calls are slow and expensive. Help me optimize the setup.
The agent reviews the current implementation, identifies issues (wrong model selection, missing caching, inefficient prompting, no batching), and applies optimizations specific to Malloy's capabilities — adjusting model parameters, adding response caching, and implementing retry logic with exponential backoff.
Guidelines
- Models separate from queries — Define sources and views in model files; write queries in separate files or notebooks
- Name your views — Reusable views (named queries) are Malloy's superpower; define common analyses once, use everywhere
- Nested queries for rich analysis — Instead of multiple separate queries, nest related analyses into a single query
- Use pick for categorization — The
pickexpression replaces SQL's verbose CASE WHEN for creating dimensions - Pipeline for progressive filtering — Chain queries with
->to progressively refine results; each step is readable - DuckDB for local analysis — Use DuckDB connection with Parquet files for fast local analytics; switch to BigQuery for production
- Malloy notebooks for exploration — Use
.malloynbfiles for iterative data exploration with inline visualization - Version your models — Malloy models are code; store in Git alongside your data pipelines