complete app
test / test (push) Successful in 9s

This commit is contained in:
2026-09-17 17:39:22 -05:00
parent 4d633a39be
commit 3d5de1dc3e
84 changed files with 24229 additions and 0 deletions
@@ -0,0 +1,21 @@
{{
config(
materialized='table',
schema='marts',
tags=["dimension"]
)
}}
WITH source AS (
SELECT arena_name, city, state_or_country, location
FROM {{ ref('arena_mappings') }}
)
SELECT
{{ dbt_utils.generate_surrogate_key(['arena_name', 'city']) }} AS arena_key,
arena_name,
city AS arena_city,
state_or_country AS arena_state_or_country,
location AS arena_location
FROM source
ORDER BY arena_name, arena_city
@@ -0,0 +1,44 @@
{{
config(
materialized='table',
schema='marts',
tags=["dimension"]
)
}}
{% set start_date_query %}
select min(game_date)::date from {{ ref('stg_games') }}
{% endset %}
{% set start_date = dbt_utils.get_single_value(start_date_query) %}
{% set end_date_query %}
select max(game_date)::date from {{ ref('stg_games') }}
{% endset %}
{% set end_date = dbt_utils.get_single_value(end_date_query) %}
WITH date_spine AS (
SELECT UNNEST(generate_series(
'{{ start_date }}'::date,
'{{ end_date }}'::date,
INTERVAL '1 day'
))::date AS date_day
)
SELECT
CAST(strftime(date_day, '%Y%m%d') AS INTEGER) AS date_key,
date_day AS full_date,
EXTRACT(YEAR FROM date_day)::int AS year,
EXTRACT(QUARTER FROM date_day)::int AS quarter_of_year,
EXTRACT(MONTH FROM date_day)::int AS month_of_year,
strftime(date_day, '%B') AS month_name,
EXTRACT(DAY FROM date_day)::int AS day_of_month,
EXTRACT(ISODOW FROM date_day)::int AS day_of_week,
strftime(date_day, '%A') AS day_of_week_name,
EXTRACT(DOY FROM date_day)::int AS day_of_year,
EXTRACT(WEEK FROM date_day)::int AS week_of_year,
CASE
WHEN EXTRACT(ISODOW FROM date_day) IN (6, 7) THEN true
ELSE false
END AS is_weekend
FROM date_spine
ORDER BY full_date
@@ -0,0 +1,36 @@
{{
config(
materialized='table',
schema='marts',
tags=["dimension"]
)
}}
WITH distinct_archetypes AS (
SELECT DISTINCT
usage_tier,
impact_tier,
shooting_efficiency_tier,
minutes_based_role,
is_double_double,
is_triple_double,
is_versatile,
is_defensive_specialist,
is_three_and_d
FROM {{ ref('int_player_performance') }}
)
SELECT
{{ dbt_utils.generate_surrogate_key([
'usage_tier',
'impact_tier',
'shooting_efficiency_tier',
'minutes_based_role',
'is_double_double',
'is_triple_double',
'is_versatile',
'is_defensive_specialist',
'is_three_and_d'
]) }} AS archetype_key,
*
FROM distinct_archetypes
@@ -0,0 +1,26 @@
{{
config(
materialized='table',
schema='marts',
tags=["dimension"]
)
}}
WITH player_game_stats AS (
SELECT
stats.player_id,
stats.player_name,
games.game_date,
ROW_NUMBER() OVER (PARTITION BY stats.player_id ORDER BY games.game_date DESC) as rn
FROM {{ ref('stg_player_game_basic_stats') }} AS stats
LEFT JOIN {{ ref('stg_games') }} AS games
ON stats.game_id = games.game_id
)
SELECT
{{ dbt_utils.generate_surrogate_key(['player_id']) }} AS player_key,
player_id,
player_name
FROM player_game_stats
WHERE rn = 1
ORDER BY player_name
@@ -0,0 +1,19 @@
{{
config(
materialized='table',
schema='marts',
tags=["dimension"]
)
}}
WITH all_seasons AS (
SELECT DISTINCT season_start_year
FROM {{ ref('int_games_enriched') }}
)
SELECT
{{ dbt_utils.generate_surrogate_key(['season_start_year']) }} AS season_key,
season_start_year,
season_start_year || '-' || SUBSTR(CAST(season_start_year + 1 AS VARCHAR), 3, 2) AS season_display
FROM all_seasons
ORDER BY season_start_year
@@ -0,0 +1,32 @@
{{
config(
materialized='table',
schema='marts',
tags=["dimension"]
)
}}
WITH zones AS (
SELECT * FROM (
VALUES
('At Rim (0-3 ft)', 0, 3, 1, 'Paint', 'Interior', 'Field Goal'),
('Short Range (4-10 ft)', 4, 10, 2, 'Paint', 'Interior', 'Field Goal'),
('Mid Range (11-16 ft)', 11, 16, 3, 'Mid Range', 'Mid Range', 'Field Goal'),
('Long Mid Range (17-23 ft)', 17, 23, 4, 'Mid Range', 'Mid Range', 'Field Goal'),
('Three Point (24-27 ft)', 24, 27, 5, 'Perimeter', 'Three Point', 'Field Goal'),
('Deep Three (28+ ft)', 28, 50, 6, 'Perimeter', 'Three Point', 'Field Goal'),
('Free Throw (15 ft)', 15, 15, 7, 'Free Throw', 'Free Throw', 'Free Throw')
) AS t(shot_distance_zone, min_distance_ft, max_distance_ft, zone_order, zone_group, zone_category, shot_class)
)
SELECT
{{ dbt_utils.generate_surrogate_key(['shot_distance_zone']) }} AS shot_zone_key,
shot_distance_zone,
min_distance_ft,
max_distance_ft,
zone_order,
zone_group,
zone_category,
shot_class
FROM zones
ORDER BY zone_order
@@ -0,0 +1,19 @@
{{
config(
materialized='table',
schema='marts',
tags=["dimension"]
)
}}
WITH team_mappings AS (
SELECT team_abbr, full_name
FROM {{ ref('team_maps') }}
)
SELECT
{{ dbt_utils.generate_surrogate_key(['team_abbr']) }} AS team_key,
team_abbr,
full_name AS team_full_name
FROM team_mappings
ORDER BY team_abbr