Skip to content

Commit

Permalink
add more columns to f_results (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
frizzleqq authored Jul 26, 2024
1 parent b7450cd commit 2162da3
Showing 1 changed file with 30 additions and 18 deletions.
48 changes: 30 additions & 18 deletions dbt/models/core/f_result.sql
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,29 @@ WITH results AS (
FROM {{ ref('ergast_results') }}
)

, qualifying AS (
-- , constructor_results AS (
-- SELECT *
-- FROM {{ ref('ergast_constructor_results') }}
-- )

, constructor_standings AS (
SELECT *
FROM {{ ref('ergast_qualifying') }}
FROM {{ ref('ergast_constructor_standings') }}
)

, constructor_results AS (
, driver_standings AS (
SELECT *
FROM {{ ref('ergast_constructor_results') }}
FROM {{ ref('ergast_driver_standings') }}
)

, constructor_standings AS (
, qualifying AS (
SELECT *
FROM {{ ref('ergast_constructor_standings') }}
FROM {{ ref('ergast_qualifying') }}
)

, driver_standings AS (
, result_status AS (
SELECT *
FROM {{ ref('ergast_driver_standings') }}
FROM {{ ref('ergast_status') }}
)

, d_circuit AS (
Expand Down Expand Up @@ -58,7 +63,7 @@ WITH results AS (
, results.positiontext AS result_position_text
, results.positionorder AS result_position_order
, results.points AS result_points
-- , results.statusId
, result_status.status AS result_status
, results.laps AS laps_completed
, results.time AS finishing_time
, results.milliseconds AS finishing_time_milliseconds
Expand All @@ -71,22 +76,29 @@ WITH results AS (
, qualifying.q1 AS qualifying1_lap_time
, qualifying.q2 AS qualifying2_lap_time
, qualifying.q3 AS qualifying3_lap_time
-- TODO: constructor results
-- TODO: constructor standings
-- TODO: driver standings
, driver_standings.points AS driver_season_points
, driver_standings.driver_position AS driver_season_position
, driver_standings.positiontext AS driver_season_position_text
, driver_standings.wins AS driver_season_wins
, constructor_standings.points AS constructor_season_points
, constructor_standings.constructor_position AS constructor_season_position
, constructor_standings.positiontext AS constructor_season_position_text
, constructor_standings.wins AS constructor_season_wins
-- TODO: constructor results?
FROM results
LEFT JOIN qualifying
ON qualifying.raceid = results.raceid AND qualifying.driverid = results.driverid
LEFT JOIN constructor_results
ON
constructor_results.raceid = results.raceid
AND constructor_results.constructorid = results.constructorid
LEFT JOIN result_status ON result_status.statusid = results.statusid
-- LEFT JOIN constructor_results
-- ON
-- constructor_results.raceid = results.raceid
-- AND constructor_results.constructorid = results.constructorid
LEFT JOIN constructor_standings
ON
constructor_standings.raceid = results.raceid
AND constructor_standings.constructorid = results.constructorid
LEFT JOIN driver_standings
ON driver_standings.raceid = results.raceid AND driver_standings.driverid = results.driverid
LEFT JOIN qualifying
ON qualifying.raceid = results.raceid AND qualifying.driverid = results.driverid
LEFT JOIN d_race
ON d_race.race_id = results.raceid
LEFT JOIN d_circuit
Expand Down

0 comments on commit 2162da3

Please sign in to comment.