malloy-queries

Write and debug Malloy queries using syntax rules, patterns, and error references.

9|Updated Feb 16, 2026
One-click install
npx skills add https://github.com/mathisdrn/orca --skill malloy-queries-mathisdrn
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: malloy-queries
Source: https://github.com/mathisdrn/orca/tree/main/.agents/skills/malloy-queries
Command: npx skills add https://github.com/mathisdrn/orca --skill malloy-queries-mathisdrn

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing Malloy queries without a reference leads to common syntax errors like comparing timestamps to integers, misplacing chart annotations, or confusing where and having clauses. This Skill provides a grounded reference of query patterns, syntax rules, and error fixes so queries compile correctly the first time. ## Core Features & Use Cases - Query Pattern Library: Ready-to-use templates for aggregations, group-bys, time trends, filtered queries, percent-of-total calculations, and window functions with calculate. - Syntax Rules Reference: Covers date literals with @, truncation accessors, reserved keywords, regex string matching with ~, join path navigation via dot notation, and chart annotation placement. - Error Diagnosis Table: Maps common Malloy error messages like "Cannot compare a timestamp to a number" or "field is a bar chart, but is not a repeated record" to their likely causes and fixes. - Use Case: When a query fails with "no viable alternative at input 'month'", consult the error table to learn that month is a reserved word and rename the alias to order_month. ## Quick Start Ask the assistant to write a Malloy query showing monthly revenue as a line chart, and it will apply these patterns and rules to produce valid syntax.

Frequently Asked Questions about malloy-queries

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write a Malloy query with group by and aggregation?▼

Use the run statement with a source, then group_by for dimensions and aggregate for measures, such as run: source -> { group_by: category aggregate: revenue order_by: revenue desc limit: 10 }. Only use field names defined in the model and never invent fields.

How do I filter Malloy queries by date range?▼

Use the ? apply operator with @ date literals, such as where: order_date ? @2025-06 to @2025-09 for a range or @2025-Q3 for a quarter. Never compare a timestamp to a bare integer like order_date.year >= 2020.

What is the difference between where and having in Malloy?▼

where filters rows before aggregation and only sees dimensions, while having filters aggregate results and only sees measures. Writing where: total_revenue > 1000 fails because total_revenue is an aggregate; use having instead.

Why does my Malloy query fail with 'no viable alternative at input'?▼

This usually means a reserved keyword like month, year, or day was used as an alias or function call, or a semicolon was used to separate fields. Rename the alias, backtick the name, or use newline-separated fields instead.

How do I count distinct values in Malloy?▼

Use count(field) for a distinct count of that field and count() for a row count. There is no count(distinct field) syntax, and count(*) is invalid in Malloy.

Where do chart annotations go in a Malloy query?▼

Chart annotations like # bar_chart or # line_chart go before run:, view:, or nest:, never inside curly braces. Placing them inside braces causes the error 'field is a bar chart, but is not a repeated record'.