charliermarsh / malloy

Malloy is an experimental language for describing data relationships and transformations.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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 currently connects to BigQuery and Postgres, and natively supports DuckDB. We've built a Visual Studio Code extension to facilitate building Malloy data models, querying and transforming data, and creating simple visualizations and dashboards.

Try the Malloy VSCode Extension

Currently, the Malloy extension works on Mac, Linux, and Windows machines.

  1. Download Visual Studio Code: Download Visual Studio Code

  2. Add the Malloy (pre-release) extension from the Visual Studio Code Marketplace: Open VS Code and click the Extensions button on the far left (it looks like 4 blocks with one flying away). This will open the Extension Marketplace. Search for "Malloy" and, once found, click "Install"

  3. Download and unzip the Sample Models (models + data).

  4. Open the samples folder in VS Code. In VS Code, go to File > Open Folder... select samples/duckdb > Open. DuckDB is built into the extension so you're ready to run these.

  5. Start with 1_airports.malloy in the FAA dataset. This is a sub-sample of the NTSB Flights dataset. In the editor pane, above source: airports, click the word "Preview" to run a SELECT *, and click the word "Run" above any query object to run it (see gif below for example).

show_run

To get to know the Malloy language, follow Malloy by Example and/or continue through the numbered models in the FAA directory.

Note: The Malloy VSCode Extension tracks a small amount of anonymous usage data. You can opt out in the extension settings. Learn more.

Join the Community

  • Join our Malloy Slack Community! Use this community to ask questions, meet other Malloy users, and share ideas with one another.
  • Use GitHub issues in this Repo to provide feedback, suggest improvements, report bugs, and start new discussions.

Resources

Documentation:

YouTube - Watch demos / walkthroughs of Malloy

Contributing

If you would like to work on Malloy, take a look at the instructions for developing Malloy and developing documentation.

To report security issues please see our security policy.

Malloy is not an officially supported Google product.

Syntax Example

Here is a simple example of a Malloy query:

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:

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

Learn more about the syntax and language features of Malloy in the Quickstart.

About

Malloy is an experimental language for describing data relationships and transformations.

License:GNU General Public License v2.0


Languages

Language:TypeScript 97.6%Language:ANTLR 1.7%Language:Shell 0.3%Language:JavaScript 0.2%Language:Ruby 0.1%Language:Batchfile 0.1%Language:Nix 0.0%