-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
25 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
>>>markdown | ||
# Unnesting Data | ||
Malloy can naturally read unnested data. Currently there is no mechanism to join something that unnest so for now you have to do it in SQL | ||
>>>malloy | ||
source: airports is duckdb.sql(""" | ||
SELECT | ||
*, | ||
SPLIT(city,' ') as city_words | ||
FROM '../data/airports.parquet' | ||
""") extend { | ||
measure: | ||
airport_count is count() | ||
} | ||
>>>markdown | ||
We can now 'city_words', the words that appear in the city column | ||
>>>malloy | ||
run: airports -> { | ||
group_by: city_word is city_words.value | ||
aggregate: airport_count | ||
# list | ||
nest: by_city is { | ||
group_by: city | ||
aggregate: airport_count | ||
} | ||
} |