-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathimdb.malloy
101 lines (84 loc) · 2.27 KB
/
imdb.malloy
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
// Information courtesy of IMDb (https://www.imdb.com).
// Used with permission.
// For personal / educational use only
//
// Github: https://github.com/lloydtabb/imdb_fiddle
// About Fiddles: https://github.com/lloydtabb/malloy_fiddle_dist/
source: people is duckdb.table('data/names.parquet') extend {
// cast, crew, everyone involved in movies
primary_key: nconst
}
source: principals is duckdb.table('data/principals.parquet') extend {
// a mapping table that links people to movies, along with their job on that movie.
join_one: people is people on nconst = people.nconst
}
source: movies is duckdb.table('data/titles.parquet') extend {
// all the movies
join_many: principals on tconst = principals.tconst
primary_key: tconst
measure:
title_count is count(tconst)
row_count is count()
total_ratings is sum(numVotes/1000.0)
average_rating is averageRating.avg()
# percent
percent_of_titles is title_count/all(title_count)
dimension:
# image
movie_image is concat('https://artifacts.flyxit.com/flyx-artifacts/',tconst,'.jpg')
# link
movie_url is concat('https://www.imdb.com/title/',tconst)
view: by_title is {
group_by: primaryTitle, startYear, numVotes
order_by: 3 desc
}
view: by_year is {
group_by: startYear
aggregate: title_count
order_by: startYear desc
}
view: by_name is {
group_by:
principals.people.primaryName, principals.nconst
aggregate:
total_ratings
title_count
}
view: by_job_category is {
group_by: job_category is principals.category
aggregate: title_count
}
view: by_genre is {
group_by: genre is genres.value
aggregate:
title_count,
total_ratings
percent_of_titles
}
view: by_character is {
group_by: principals.characters.value
aggregate: title_count
}
view: by_year_and_genre is by_year + {
nest: by_genre
}
# dashboard
view: titles_dashboard is {
group_by:
movie_image
production_year is startYear
primaryTitle
runtimeMinutes
movie_url
nest:
genre_list is by_genre
by_cast is by_job_category {
# list
nest: names is by_name + {limit: 200}
}
limit: 20
order_by: 2 desc
}
}
// example query
run: movies -> by_name