Skip to content

Commit

Permalink
add example
Browse files Browse the repository at this point in the history
  • Loading branch information
lloydtabb authored Oct 6, 2023
1 parent 7ad838d commit 05c7c0d
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions patterns/unnest_data.malloynb
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
}
}

0 comments on commit 05c7c0d

Please sign in to comment.