Why Malloy
What Malloy is, its open-source license and governance, how it compares with SQL, LookML and YAML-based metric layers, and why Credible data models are written in it
Every Credible data model is written in Malloy (opens in a new tab), an open-source language for modeling and querying data.
What Malloy Is
Malloy is a language for describing data and asking questions of it. A Malloy model declares sources, joins, dimensions, measures and views; Malloy queries run against that model. The compiler turns each query into SQL for the database it targets, including BigQuery, Snowflake, PostgreSQL, MySQL, Databricks, Trino and DuckDB, and the database runs that SQL.
Malloy was created by Lloyd Tabb, a co-founder of Looker and the author of LookML. It is open source under the MIT license and is a Linux Foundation project. The source is on GitHub (opens in a new tab), and the language reference is at docs.malloydata.dev (opens in a new tab).
For a side-by-side with SQL, see Malloy vs. SQL.
Freedom and Safety
The common alternatives trade expressiveness against safety:
- Raw SQL can express anything but has no way to save a calculation as a reusable definition, so definitions drift between queries.
- LookML and YAML-based metric layers (such as dbt's MetricFlow or Cube) give a governed set of definitions, but they are configuration formats that embed SQL snippets. Logic the format can't express is written as raw SQL, outside the checks the format provides.
Malloy is a full query language as well as a modeling language, so the same language defines the model and asks questions of it. That allows:
- Composition. Dimensions build on other dimensions, and a source can extend another source and add only what differs.
- Nesting. A query can return nested results, such as revenue by region with a monthly breakdown inside each region, in one query.
- Pipelines. The output of one query stage can feed the next, for multi-step analysis in one definition.
When you need a database-specific feature, Malloy can define a source from a SQL query (warehouse.sql(...)) or embed a SQL expression in a field. Malloy reads a SQL source's columns and types from the database, so everything built on it is still checked.
For how the term "semantic layer" relates to Malloy and to Credible, see Malloy and the semantic layer.
The Whole Model in One Place
Malloy annotations keep documentation, search hints, access rules and materialization next to the definitions they describe:
#(doc) Net revenue recognized at order completion, in USD
measure: total_revenue is sum(order_amount)#(doc)and#(index)describe fields and make their values searchable. See Descriptions and Value Search.#(authorize)and#(access_filter)restrict which callers can query a source and which rows they see. See Row and Column Access.#@ persistasks the engine to build a source as a table. See Materialization and Performance.
The whole model is plain text files: reviewable in a pull request, checked in CI, and published as a versioned package.
Built for AI
Credible uses Malloy because it suits agents that write and read queries:
- Queries are checked before they run. Malloy queries are short and declarative, and the compiler checks each one against the model. A query that references a field that doesn't exist fails with an error that names the field, so the agent can correct it.
- The model carries the meaning. Definitions, relationships, documentation and access rules sit together in the model, which is the context an agent needs to answer with your definitions.
- Answers match other surfaces. An agent's query uses the same measures as a dashboard's, under the same access rules.
Open-source Malloy agent skills teach agents to model and analyze in Malloy.
Open Source and Portable
Your models are Malloy text files that you own. The engine that serves them, Malloy Publisher (opens in a new tab), is also open source under the MIT license and is maintained by Credible. It serves Malloy models over REST and MCP, and you can run it yourself. Credible runs the same engine as a managed service and adds connections, permissions, the gateway, the index and the app around it.