Skip to content

Commit be96379

Browse files
authored
Merge pull request #2 from Shanabunga/add-staging
Add Sources & Staging Models
2 parents a9591ff + 7801cab commit be96379

13 files changed

Lines changed: 226 additions & 55 deletions

dbt_project.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@ clean-targets: # directories to be removed by `dbt clean`
3232
models:
3333
ssp_analytics:
3434
# Config indicated by + and applies to all files under models/example/
35-
example:
35+
staging:
3636
+materialized: view

models/example/my_first_dbt_model.sql

Lines changed: 0 additions & 27 deletions
This file was deleted.

models/example/my_second_dbt_model.sql

Lines changed: 0 additions & 6 deletions
This file was deleted.

models/example/schema.yml

Lines changed: 0 additions & 21 deletions
This file was deleted.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
version: 2
2+
3+
models:
4+
- name: stg_gsheets__franchise_actives
5+
- name: stg_gsheets__franchise_general_managers
6+
- name: stg_gsheets__franchise_head_coaches
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
version: 2
2+
3+
sources:
4+
- name: franchises
5+
database: analytics
6+
schema: raw_google_sheets
7+
tables:
8+
- name: actives
9+
identifier: franchise_actives
10+
- name: general_managers
11+
identifier: franchise_general_managers
12+
- name: head_coaches
13+
identifier: franchise_coaches
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
with
2+
3+
source_table as (
4+
select * from {{ source('franchises', 'actives') }}
5+
),
6+
7+
final as (
8+
9+
select
10+
TEAM_ID::int as team_id,
11+
FRANCHISE_ID::int as franchise_id,
12+
FRANCHISE_NAME as franchise_name,
13+
URL as url,
14+
"start"::int as year_started,
15+
"end"::int as year_ended,
16+
YEARS::int as years_active,
17+
GP::int as games_played,
18+
WINS::int as wins,
19+
LOSSES::int as losses,
20+
WIN::numeric / 100 as winning_percentage,
21+
PO::int as playoffs_made,
22+
DIV__TITLES::int as division_titles,
23+
CONF__TITLES::int as conference_titles,
24+
LEAGUE_TITLES::int as league_titles,
25+
"end" is null as is_current
26+
27+
from source_table
28+
29+
)
30+
31+
select * from final
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
with
2+
3+
source_table as (
4+
select * from {{ source('franchises', 'general_managers') }}
5+
),
6+
7+
final as (
8+
9+
select
10+
ID as general_manager_id,
11+
TEAM as team_name,
12+
COLLEGE as college_name,
13+
DIVISION as division,
14+
CONFERENCE as conference,
15+
16+
case
17+
when GENERAL_MANAGER = 'Vacant'
18+
then null
19+
else GENERAL_MANAGER
20+
end as general_manager,
21+
22+
PROFESSIONAL_CAREER as professional_career,
23+
YEAR_HIRED::int as year_hired,
24+
AS_OF_DATE::date as as_of_date,
25+
26+
date_part('year', AS_OF_DATE::date) - YEAR_HIRED::int as years_active
27+
28+
from source_table
29+
30+
)
31+
32+
select * from final
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
with
2+
3+
source_table as (
4+
select * from {{ source('franchises', 'head_coaches') }}
5+
),
6+
7+
final as (
8+
9+
select
10+
ID as head_coach_id,
11+
HEAD_COACH as head_coach,
12+
TEAM as team_name,
13+
DIVISION as division,
14+
CONFERENCE as conference,
15+
START_DATE::date as start_date,
16+
AS_OF_DATE::date as as_of_date,
17+
date_part('year', AS_OF_DATE::date) - date_part('year', START_DATE::date) as years_active
18+
19+
from source_table
20+
21+
)
22+
23+
select * from final
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
version: 2
2+
3+
models:
4+
- name: stg_nba__games
5+
- name: stg_nba__teams

0 commit comments

Comments
 (0)