Skip to content
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/documentation/user_guides/basic.malloynb
Original file line number Diff line number Diff line change
Expand Up @@ -110,15 +110,15 @@ The basic types of Malloy expressions are `string`, `number`, `boolean`, `date`,

One of the main benefits of Malloy is the ability to save common calculations into a data model. The data model is made of *sources*, which can be thought of as tables or views, but with additional information, such as joins, dimensions and measures.

In the example below, we create a *source* object named `airports` and add a `dimension` calculation for `county_and_state` and `measure` calculation for `airport_count`. Dimensions can be used in `group_by`, `project` and `where`. Measures can be used in `aggregate` and `having`.
In the example below, first we create a *source* object named `airports` and add a `dimension` calculation for `county_and_state` and `measure` calculation for `airport_count`. We then query the `airports` source, grouping by the `county_and_state` dimension and aggregating with the `airport_count` measure.
Dimensions can be used in `group_by`, `project` and `where`. Measures can be used in `aggregate` and `having`.
>>>malloy
source: airports is duckdb.table('../data/airports.parquet') extend {
dimension: county_and_state is concat(county, ', ', state)
measure: airport_count is count()
measure: average_elevation is avg(elevation)
}
>>>markdown
>>>malloy

run: airports -> {
group_by: county_and_state
aggregate: airport_count
Expand All @@ -128,7 +128,7 @@ run: airports -> {
Sources that are defined in one file can be imported into another using `import "path/to/some/file.malloy"`. For example, if the `airports` source above were defined in a file called `flights.malloy`, you could create a new file that imports it and immediately start using the `airports` source:
>>>markdown
```malloy
import "airports.malloy"
import "flights.malloy"
Comment thread
goomrw marked this conversation as resolved.
Outdated

run: airports -> {
group_by: county_and_state
Expand Down