malloy

Malloy specialist: guidance for Google's experimental data language Malloy. Malloy uses a composable, reusable, and more readable syntax as an alternative to SQL for data analysis. Helps write Malloy models, build nested queries, and explore data via Malloy's VS Code extension and notebook interface.

Last repository push
GitHub Stars
219
Forks
38
Issues / PRs
1

Installation

Review the source and dependencies with a prompt. A package is available to download.

Install with an AI assistant

Copy the prompt so your assistant can review the pinned revision and dependencies first.

View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "malloy" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-a8a4d2bfc99a109e0966b255c06d05a02e991984d5cb3eb811144d37256b2469. Verify the upstream source and version against https://github.com/TerminalSkills/skills before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.

Source and setup

github.com

Setup guidance pending

See the original source for supported tools, dependencies, and permissions.

Installation test pending

Malloy specialist: guidance for Google's experimental data language Malloy. Malloy uses a composable, reusable, and more readable syntax as an alternative to SQL for data analysis. Helps write Malloy models, build nested queries, and explore data via Malloy's VS Code extension and notebook interface.

0 Downloads

Introduction source: third_party · TerminalSkills · 1.0.0 Reference

SkillPi interpretation

Tasks
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.
Testing
Not tested

Browse files

Browse files at the source ↗

Original SKILL.md

Open original ↗
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-language

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

  1. Models separate from queries — Define sources and views in model files; write queries in separate files or notebooks
  2. Name your views — Reusable views (named queries) are Malloy's superpower; define common analyses once, use everywhere
  3. Nested queries for rich analysis — Instead of multiple separate queries, nest related analyses into a single query
  4. Use pick for categorization — The pick expression replaces SQL's verbose CASE WHEN for creating dimensions
  5. Pipeline for progressive filtering — Chain queries with -> to progressively refine results; each step is readable
  6. DuckDB for local analysis — Use DuckDB connection with Parquet files for fast local analytics; switch to BigQuery for production
  7. Malloy notebooks for exploration — Use .malloynb files for iterative data exploration with inline visualization
  8. Version your models — Malloy models are code; store in Git alongside your data pipelines

Current listing version

1.0.0

Verify the source revision ↗

Safety and assessment details

Quality assessment

Out of 100 · Assessment report from SkillPi LAB.

Scenario Value85/100

Highlights

  • 提供 Malloy 语言的全面指导,涵盖模型定义、查询编写、连接配置和可视化
Trigger Precision90/100

Highlights

  • description 明确描述了 Skill 的功能和适用场景,覆盖合理
Structure and Standards95/100

Highlights

  • 结构清晰,包含多个实用章节,步骤分明,有丰富代码示例
Execution Reliability90/100

Areas to improve

  • BigQuery 连接配置说明不完整 Reported severity: Minor

    Installation 部分缺少对 BigQuery 连接的详细配置说明(如认证方式)

    Recommendation: 补充 BigQuery 连接的认证配置说明,提高执行可靠性

Highlights

  • 提供了多种安装方式,工具来源明确,参数正确
Evidence Verifiability (mean of the first four)90/100

The arithmetic mean of the first four original scores, rounded to a whole number.

Static text checks

100 / 100 · skillpi-20261123-no-r3-v1

No current rules matched the text.

This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.

Permissions and checks before use

Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.

  • Install or fetch external dependencies

    Use official sources and pin versions. Check install scripts in an isolated environment. This document check does not cover code downloaded later.

    Mentioned in main document · lines 252, 255
  • Accounts, secrets or authorization

    Use a dedicated least-privilege account. Keep secrets out of public content and command logs; verify the receiving service and tenant.

    Mentioned in main document · lines 273

These notices grant no permissions. Your host tool must still confirm file changes, secrets, external transfers or costs as needed.

Security rating and access scope

safe · Static evidence review; not a runtime safety guarantee.

Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.