forked from malloydata/learn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsemantic_1.malloynb
42 lines (39 loc) · 1.21 KB
/
semantic_1.malloynb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
>>>malloy
source: products is duckdb.table('data/ecommerce/products.parquet')
source: users is duckdb.table('data/ecommerce/users.parquet') {
measure: average_age is age.avg()
}
source: inventory_items is duckdb.table('data/ecommerce/inventory_items.parquet') {
measure: average_cost is cost.avg()
}
source: items is duckdb.table('data/ecommerce/items.parquet') {
join_one: products on product_id = products.product_id
join_one: inventory_items on inventory_item_id = inventory_items.inventory_item_id
measure:
total_revenue is sale_price.sum()
average_item_price is sale_price.avg()
}
source: orders is duckdb.table('data/ecommerce/orders.parquet') {
join_many: items on order_id = items.order_id
join_one: users on user_id = users.user_id
}
>>>malloy
run: orders -> {
group_by: items.products.category
aggregate:
items.total_revenue
items.average_item_price
users.average_age
items.inventory_items.average_cost
}
>>>malloy
source: airports is duckdb.table('data/faa/airports.parquet') {
measure:
airport_count is count()
average_elevation is elevation.avg()
query: by_state is {
group_by: state
aggregate: airport_count, average_elevation
}
}
run: airports -> by_state