rel:: [[Programming Languages]]
rel:: [Against SQL](x-devonthink-item://C236F225-B503-41F6-AA74-CEB634A77D15)
# Malloy
From [project github page](https://github.com/looker-open-source/malloy)
> Malloy is an experimental language for describing data relationships and transformations. It is both a semantic modeling language and a querying language that runs queries against a relational database. Malloy is currently available on BigQuery and [[PostgreSQL]]. About Malloy:
- Queries compile to [[SQL]]
- Computations are modular, composable, reusable, and extendable
- Excels at querying and producing nested data sets
## Reference
- [source](https://github.com/looker-open-source/malloy)
- [docs](https://looker-open-source.github.io/malloy/documentation/index.html)
- [quickstart](https://looker-open-source.github.io/malloy/documentation/language/basic.html)
- [panned pretty hard on hacker news](https://news.ycombinator.com/item?id=30053860#30056290)
### Syntax Example
```
query: table('malloy-data.faa.flights') -> {
where: origin: 'SFO'
group_by: carrier
aggregate:
flight_count is count()
average_flight_time is flight_time.avg()
}
```
In SQL this would be expressed:
```SQL
SELECT
carrier,
COUNT(*) as flight_count,
AVG(flight_time) as average_flight_time
FROM `malloy-data.faa.flights`
WHERE origin = 'SFO'
GROUP BY carrier
ORDER BY flight_count desc -- malloy automatically orders by the first aggregate
```