Skip to main content
Malloy is an open-source semantic modeling language designed to make complex data analysis intuitive and maintainable. It treats data as a network of relationships and provides mathematical precision for computations like aggregation, making it an ideal foundation for building semantic models. Malloy compiles to optimized SQL, running on databases like BigQuery, Postgres, and DuckDB, while providing a more expressive and composable modeling experience.

Design Philosophy

Declarative and Mathematical

With SQL, you must tell the database how to perform an operation, specifying join types, groupings, and subqueries. This imperative approach can obscure the business logic. Malloy is declarative—you describe what data you want rather than how to get it. The language comprehends data as a network of relationships, making computations mathematically precise and automatically handling complex join scenarios like fanout prevention.

Composable and Reusable

Malloy treats data models like function libraries. Calculations, relationships, and query patterns can be defined once and reused across different analytical contexts. This composability enables sophisticated analysis while maintaining clarity and avoiding repetition.

Curated Yet Flexible

The language provides one clear way to express most concepts, offering sensible defaults while remaining flexible enough to handle complex analytical requirements. It’s concise but not cryptic, prioritizing clarity in data modeling.

Key Capabilities

Intelligent Aggregation

Malloy’s aggregation system understands data relationships automatically. Aggregates can be defined once at the source level and used across different query granularities. The language maintains the data graph’s integrity throughout complex transformations, preventing common issues like double-counting in multi-table joins.

Natural Nesting

Malloy natively supports nested queries and subtables, enabling complex analytical patterns like drilling down within results or calculating metrics at multiple levels of detail. This makes dashboard-like results straightforward to create and understand.

Advanced Analytical Operations

The language provides powerful primitives for operations that are challenging to express in traditional SQL:
  • Level-of-detail calculations: Computing metrics at different grains within the same query
  • Time-based analysis: Simplified filtering and calculations across time periods
  • Dimensional transformations: Bucketing, mapping, and data cleanup operations

Rich Metadata and Visualization Support

Queries return comprehensive metadata about results, supporting advanced visualization and interactive exploration. This metadata enables tools to provide intuitive data exploration experiences.

Semantic Modeling Strengths

Encapsulation of Business Logic

Calculations and relationships are bundled with the data they describe. A metric like customer_lifetime_value is defined once on the customer source and maintains consistent meaning wherever it’s referenced, ensuring organizational consistency.

Model Evolution and Extension

Sources can be extended and refined without duplicating code. You can create specialized models (like enterprise_customers) that inherit from base models while adding specific business logic or filters.

Query Pipelining

Malloy supports sophisticated query pipelining, allowing you to chain transformations and build complex analytical workflows. This enables iterative data exploration and sophisticated analysis patterns.

A Living Language

Malloy is designed as a “living language” that evolves with the needs of data practitioners. It’s open source and committed to backward compatibility, providing a stable foundation for long-term semantic modeling projects. The language is built with empathy for data explorers and analysts, supporting iterative decision-making and comprehensive data interaction. It’s more than a query language—it’s a methodology for understanding and working with data relationships.

Learn More

I