https://github.com/malloydata/patterns
Malloy Design Patterns in Notebooks
https://github.com/malloydata/patterns
Last synced: 5 months ago
JSON representation
Malloy Design Patterns in Notebooks
- Host: GitHub
- URL: https://github.com/malloydata/patterns
- Owner: malloydata
- License: mit
- Created: 2023-03-08T17:01:54.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-09-13T14:25:46.000Z (almost 3 years ago)
- Last Synced: 2026-01-08T21:55:54.444Z (6 months ago)
- Size: 10.3 MB
- Stars: 12
- Watchers: 2
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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](other.malloynb)
## 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](growth.malloynb)
## Row Totals in Malloy
Malloy currently doesn't support rendering tables with totals, but you can simple compute them.
[Row Totals](totals.malloynb)
## 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](level_of_detail.malloynb)
## 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](nested_data.malloynb)
## 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](flight_routes.malloynb)
## 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](auto_bin.malloynb)
## 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](dedup_rows.malloynb)
## 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](api_json.malloynb)
## 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](index.malloynb)