malloy
安装方式
先用 Prompt 核对来源与依赖。也可下载安装包。
用 AI 助手安装
复制提示词,让助手先核对固定版本和依赖。
查看 Prompt收起 Prompt
先检查当前 Agent 是否已安装 SkillPI Skill Finder。如果尚未安装,请按官方仓库的说明安装并启用:https://github.com/Findskills/skillpi。然后使用 Skill Finder 打开此 SkillPI 详情页并定位 "malloy":https://skillpi.com/zh/skills/deepskill-a8a4d2bfc99a109e0966b255c06d05a02e991984d5cb3eb811144d37256b2469。安装前核对上游来源和版本:https://github.com/TerminalSkills/skills。来源不一致时停止并说明差异。核对通过后,用 Skill Finder 安装目标 Skill,并报告安装路径和来源版本。
来源与配置
github.com
配置方式待核实
请查看原始来源中的适用工具、依赖和权限要求。
安装实测待补充
Malloy 专家:为 Google 的实验性数据语言 Malloy 提供指导。Malloy 使用可组合、可复用且更易读的语法,作为替代 SQL 的数据分析语言。帮助编写 Malloy 模型、构建嵌套查询,并通过 Malloy 的 VS Code 扩展和笔记本界面探索数据。
介绍来源: third_party · TerminalSkills · 1.0.0 参考来源
SkillPi 解读
- 能完成的任务
- 翻译待完成,请参阅来源文档。
- 实测状态
- 未测试
文件浏览
Frontmatter
name: malloy
description: 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.
license: Apache-2.0
compatibility: No special requirements
metadata:
author: terminal-skills
version: 1.0.0
category: data-ai
tags:
- sql
- analytics
- semantic-model
- data-exploration
- query-languageMalloy — 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
当前收录版本
1.0.0
安全与评测信息
质量评测
满分100 · 来自 SkillPi LAB 实验室的评测报告。
亮点
- 提供 Malloy 语言的全面指导,涵盖模型定义、查询编写、连接配置和可视化
亮点
- description 明确描述了 Skill 的功能和适用场景,覆盖合理
亮点
- 结构清晰,包含多个实用章节,步骤分明,有丰富代码示例
待提升项
-
BigQuery 连接配置说明不完整 原报告严重程度:轻微
Installation 部分缺少对 BigQuery 连接的详细配置说明(如认证方式)
改进建议:补充 BigQuery 连接的认证配置说明,提高执行可靠性
亮点
- 提供了多种安装方式,工具来源明确,参数正确
取前四项原始分值的算术平均,四舍五入取整。可通过收录报告核对各项评分与说明,运行记录需单独查证。
正文静态检测
100 / 100 · skillpi-20261123-no-r3-v1
正文未命中当前规则。
分数仅反映正文中的规则命中,供使用前参考。附件与运行行为不在此评分范围内。
权限与使用前检查
根据当前主文档自动整理,命中内容可能是示例或防护说明;不是实际权限声明,也未覆盖附件、外部依赖或运行行为。
-
安装或获取外部依赖
使用官方来源并锁定版本,在隔离环境检查安装脚本。当前文档检查不覆盖后续下载的代码。
主文档提及 · 第 252, 255 行 -
账号、密钥或授权
使用专用、最小权限账号,不把密钥粘贴到公开内容或命令日志;核对接收数据的服务与租户。
主文档提及 · 第 273 行
安全评级与访问范围
safe · 静态证据核验,不代表运行安全保证。
使用前请由宿主核对并授权实际文件读写、外部服务和联网目的地;本站的核验不会授予任何运行权限。
用户讨论
还没有已核实的点评。