Nifi init

This commit is contained in:
2026-05-17 16:54:29 +02:00
parent 6203332841
commit 9cc58c20f4
15 changed files with 161 additions and 0 deletions

View File

@@ -0,0 +1,18 @@
-- Generates one row per calendar date covering the full EWC 2025 event window.
-- Run on MySQL source DB.
WITH RECURSIVE dates AS (
SELECT DATE('2025-07-08') AS d
UNION ALL
SELECT DATE_ADD(d, INTERVAL 1 DAY) FROM dates WHERE d < '2025-08-24'
)
SELECT
CAST(DATE_FORMAT(d, '%Y%m%d') AS UNSIGNED) AS date_key,
d AS full_date,
YEAR(d) AS year,
QUARTER(d) AS quarter,
MONTH(d) AS month,
MONTHNAME(d) AS month_name,
WEEK(d, 1) AS week_number,
DAYOFMONTH(d) AS day_of_month,
DAYNAME(d) AS day_name
FROM dates;

View File

@@ -0,0 +1,2 @@
SELECT game_id, name, game_type, platform
FROM game;

View File

@@ -0,0 +1,2 @@
SELECT country_id, name, region
FROM country;

View File

@@ -0,0 +1,10 @@
SELECT
o.organization_id,
o.name,
o.region,
c.name AS country,
o.club_partner_status,
o.founded_year,
o.social_media_followers_m
FROM organization o
LEFT JOIN country c ON o.country_id = c.country_id;

View File

@@ -0,0 +1,18 @@
-- Returns one row per tournament with all natural keys needed for Oracle DIM lookups.
-- winner_org_id is NULL when the winner is an individual (Chess, StarCraft II, etc.)
SELECT
t.game_id,
CAST(DATE_FORMAT(t.start_date, '%Y%m%d') AS UNSIGNED) AS start_date_key,
CAST(DATE_FORMAT(t.end_date, '%Y%m%d') AS UNSIGNED) AS end_date_key,
o.organization_id AS winner_org_id,
t.event_name,
t.gender,
t.prize_pool_usd,
t.num_participants,
COALESCE(s.duration_days,
DATEDIFF(t.end_date, t.start_date) + 1) AS duration_days,
CASE WHEN t.club_championship_points = 1 THEN 1 ELSE 0
END AS has_club_points
FROM tournament t
LEFT JOIN schedule s ON t.tournament_id = s.tournament_id
LEFT JOIN organization o ON o.name = t.winner;

View File

@@ -0,0 +1,16 @@
-- Returns one row per player-medal with natural keys and pre-computed measures.
SELECT
t.game_id,
m.country_id,
m.organization_id,
m.medal AS medal_type,
CAST(DATE_FORMAT(t.start_date, '%Y%m%d') AS UNSIGNED) AS date_key,
m.player_name,
1 AS medal_count,
CASE m.medal
WHEN 'Gold' THEN 3
WHEN 'Silver' THEN 2
ELSE 1
END AS medal_points
FROM medalist m
JOIN tournament t ON m.tournament_id = t.tournament_id;

View File

@@ -0,0 +1,9 @@
SELECT
organization_id,
`rank` AS final_rank,
total_points,
prize_money_usd,
tournament_wins,
top_8_finishes,
CASE WHEN eligible_to_win = 1 THEN 1 ELSE 0 END AS eligible_to_win
FROM club_championship_standing;