/malloy-samples

Malloy model examples and associated datasets

Primary LanguageTypeScriptMIT LicenseMIT

Malloy Analysis Examples (and datasets)

This repository contains example data analysis and common patterns for expressed in Malloy. Each of the examples can be run from Notebooks. The 'patterns' are designed to be small and simple and show off how to acomplish some task. The examples are designed to show how to setup a more.

If you are reading this on Github, you can run these examples directly from your web browser.

  • Make sure you are logged into Github
  • press '.' (the period key)
  • Install the Malloy Extension

Getting Started

  • Hello World Example - A very simple example with a single table shows how to query data in Malloy

Data Analysis Patterns

  • Comparing Timeframes - There are several different ways of doing timeframe comparisons.
  • Foreign Sums - Malloy can aggregate safely anywhere in a network of joins. Example explains the different patterns.
  • Reading Nested Data - JSON, Parquet, Protobuff, log data is often a graph, not a table. Malloy can naturally read and aggregate from anywhere in this graph.
  • Percent of Total - Malloy provides 'level of detal' calculations that, among other things makes calculating percent of total easy at any level of heirachy.
  • Cohort Analysis - It is often useful to see how groups of people behave over time.
  • Nested Subtotals - With a single table we can only look at one or two perspectives at a time. With nesting, this is unlimited.
  • Other - Creating an Other Bucket - Looking at several groups and combining the rest into 'Other'.
  • Auto-bining Historgrams - In many tools, you need to fix the axis for histograms. In malloy we can dynamically figure out the approiate bucketing for the data.
  • Moving Average - Moving averages can give a better idea of trends.
  • Data from JSON API - We can use a JSON API endpoint as a data source.
  • Sessionize/Map Reduce - A common data pattern is to read events and combine them into session.
  • Dimensional Indexes - Malloy can find the most common values in your dataset.
  • Arrays - Unnesting Data - Some functions return arrays. How to work with them in Malloy.

Examples

These examples require a Google Cloud login.

Additional Resources: