Malloy Documentation

SQL is a powerful language that can express any possible query, but it has its downsides: everything is expressible, but nothing is reusable; simple ideas are complex to express; the language is verbose and lacks smart defaults. Malloy is immediately understandable by SQL users, and far easier to use and learn.

Reusable Analytical Data Model

Common calculations, table relationships and reusable queries can all be encoded in a Malloy Data Model. Malloy queries (equivalent of SQL's SELECT) run against the data model and produce SQL.

Filtering Data

Often, the first step in working with data is isolating the data you are interested in. Malloy introduces simplified filtering for all types and allows these filters to be applied. Time calculations are powerful and understandable.

Reusable Aggregates

In a Malloy Data Model, an aggregate computation need only be defined once (for example revenue). Once defined, it can be used in any query at any level of granularity or dimensionality. Malloy retains enough information in the data graph to perform this calculation no matter how you ask for it. Reusable Aggregates help improve accuracy.

Reusable Dimensional calculations

Dimensions (scalar calculations) can also be introduced into the model. Dimensional calculations are useful mapping values, bucketing results, and data cleanup.

Maintains Relationships

SQL's SELECT statement flattens the namespace into a wide table. Malloy retains the graph relationship of data and lets you access and correctly perform computations at any place in the graph.

Reusable Queries

Queries can be introduced into a Malloy model and accessed by name. Think of a Malloy model as a data function library. Views can also be used to create nested subtables in other queries.

Aggregating Subqueries

Malloy easily produces nested results. Entire dashboards can be fetched in a single query. Named views of a given shape can easily be nested, visualized and reused.


Malloy can pipeline operations. The output of one query can be the input for next.

Metadata, Visualization and Drilling

Compiling a Malloy query returns metadata about the structure of the results. When combined with the query results, Malloy's rendering library can give a very rich user experience, rendering dashboards, visualizations. Through this metadata the visualization library can rewrite queries to drill through to data detail.