Skip to content

Commit fb484e9

Browse files
author
Student
committed
add marts; nba_games_detail
1 parent e87b812 commit fb484e9

3 files changed

Lines changed: 92 additions & 1 deletion

File tree

dbt_project.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,7 @@ models:
3737
+schema: staging
3838
warehouse:
3939
+materialized: table
40-
+schema: warehouse
40+
+schema: warehouse
41+
marts:
42+
+materialized: table
43+
+schema: marts

models/marts/_marts__models.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
version: 2
2+
3+
models:
4+
- name: nba_games_detail
5+
columns:
6+
- name: game_id
7+
data_tests:
8+
- unique
9+
- not_null

models/marts/nba_games_detail.sql

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
with
2+
3+
fct_games_played as (
4+
select * from {{ ref('fct_games_played') }}
5+
),
6+
7+
dim_games as (
8+
select * from {{ ref('dim_games') }}
9+
),
10+
11+
dim_teams as (
12+
select * from {{ ref('dim_teams') }}
13+
),
14+
15+
dim_calendar_dates as (
16+
select * from {{ ref('dim_calendar_dates') }}
17+
),
18+
19+
final as (
20+
21+
select
22+
dim_games.game_id,
23+
dim_games.game_date,
24+
dim_calendar_dates.short_weekday_name,
25+
dim_calendar_dates.short_month_name,
26+
dim_calendar_dates.short_month_year,
27+
dim_games.status_long,
28+
29+
home_teams.team_name as home_team_name,
30+
home_teams.head_coach as home_team_head_coach,
31+
home_teams.general_manager as home_team_general_manager,
32+
home_teams.division as home_team_division,
33+
home_teams.conference as home_team_conference,
34+
35+
away_teams.team_name as away_team_name,
36+
away_teams.head_coach as away_team_head_coach,
37+
away_teams.general_manager as away_team_general_manager,
38+
away_teams.division as away_team_division,
39+
away_teams.conference as away_team_conference,
40+
41+
fct_games_played.home_team_score_total,
42+
fct_games_played.home_team_score_quarter_1,
43+
fct_games_played.home_team_score_quarter_2,
44+
fct_games_played.home_team_score_quarter_3,
45+
fct_games_played.home_team_score_quarter_4,
46+
fct_games_played.home_team_score_overtime,
47+
fct_games_played.average_home_pts_per_quarter,
48+
49+
fct_games_played.away_team_score_total,
50+
fct_games_played.away_team_score_quarter_1,
51+
fct_games_played.away_team_score_quarter_2,
52+
fct_games_played.away_team_score_quarter_3,
53+
fct_games_played.away_team_score_quarter_4,
54+
fct_games_played.away_team_score_overtime,
55+
fct_games_played.average_away_pts_per_quarter,
56+
57+
fct_games_played.point_differential,
58+
fct_games_played.home_team_win_count,
59+
fct_games_played.away_team_win_count
60+
61+
from fct_games_played
62+
63+
left join dim_games
64+
on fct_games_played.game_sk = dim_games.game_sk
65+
66+
left join dim_teams as home_teams
67+
on fct_games_played.home_team_sk = home_teams.team_sk
68+
69+
left join dim_teams as away_teams
70+
on fct_games_played.away_team_sk = away_teams.team_sk
71+
72+
left join dim_calendar_dates
73+
on fct_games_played.game_date_sk = dim_calendar_dates.calendar_date_sk
74+
75+
where dim_games.status_long != 'Not Started'
76+
77+
)
78+
79+
select * from final order by game_date desc -- For a cleaner view

0 commit comments

Comments
 (0)