Skip to content

malloydata/patterns

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

64 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Malloy Design Patterns

To run these examples

  • Log into Github
  • press . (the period key) to run vscode
  • Install the Malloy Extension when prompted (or manually)

Tables and Charts with 'OTHER'

Often you want to limit the results to the top reusults. This example shows how to bucket everything else into an 'OTHER' bucket

Other Buckets

A Simple Growth Calculation

Growth is this period minus last period divided by last period. Here is how you do it simply in Malloy

Compute Growth

Row Totals in Malloy

Malloy currently doesn't support rendering tables with totals, but you can simple compute them.

Row Totals

Level of Detail Calculations (ungrouped aggregates)

Malloy has the ability to escape grouping in a query. This is very useful for percent_of_total calculations among other things.

Level of Detail Calculations

Working with Nested Data

Malloy natively understands how to work with tables that have nested structs and arrays (including raw JSON) and makes easy to query and transform.

Nested Data

Sessionization

Take list of individual flights and map/reduce into individual aircraft sessions per day. Display their routes for each day on a map. Classic Map/Reduce.

Flight Route Sessinization

Automatic Historgrams

When drawing an histogram, you need to figure out a proper bin size to group the data. This pattern dyamically computes bin sizing. The binning automatically adusts with in filtered and nesting situations.

Automatic Historgrams

Deduping Rows of Data (or basing a query on SQL)

Sometime data comes in with duplicates. We can base a query on a SQL Query to remove duplicates

Dedup Rows

Querying Data directly from a Web API

Using DuckDB wwe can query from Web API endpoints. This example pulls from the github and runs some transformation queries against the results

HTTP API Queries

Indexing the entire source graph

Malloy has a special 'index' operator that produces a result that contains all the dimensional values in a graph weighed by whatever measure you think is important. The index can be built by reading the whole graph or sampling a subset of records. The index is useful in suggesting filters and for basic understanding of a data set and perhaps informing an LLM.

Malloy Dimensional Indexes

About

Malloy Design Patterns in Notebooks

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published