-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #32 from kevinsunny1996/task/fix_duplicates_and_fi…
…x_ordering add bridge surrogate keys to fix duplicates
- Loading branch information
Showing
13 changed files
with
70 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 6 additions & 3 deletions
9
dags/dbt/games_analyzer_rawg_api/models/bridge/bridge_games_genre.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,17 @@ | ||
-- depends_on: {{ ref('stg_games') }} | ||
-- depends_on: {{ ref('fct_games') }} | ||
|
||
{{config( | ||
materialized = 'incremental' | ||
materialized = 'incremental', | ||
unique_key = 'bridge_gg_id', | ||
incremental_strategy = 'merge' | ||
)}} | ||
|
||
SELECT | ||
{{ dbt_utils.generate_surrogate_key(['game_id','genre_id']) }} AS bridge_gg_id, | ||
game_id, | ||
genre_id | ||
FROM {{ ref('stg_genres') }} | ||
{% if is_incremental() %} | ||
WHERE load_date >= (SELECT COALESCE(MAX(load_date), '1900-01-01') FROM {{ this }}) | ||
AND game_id IN (SELECT game_id FROM {{ ref('stg_games') }} WHERE metacritic != 'None') | ||
AND game_id IN (SELECT game_id FROM {{ ref('fct_games') }} WHERE metacritic_score != 'None') | ||
{% endif %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 7 additions & 3 deletions
10
dags/dbt/games_analyzer_rawg_api/models/bridge/bridge_games_platforms.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,19 @@ | ||
-- depends_on: {{ ref('stg_games') }} | ||
-- depends_on: {{ ref('fct_games') }} | ||
|
||
{{config( | ||
materialized = 'incremental' | ||
materialized = 'incremental', | ||
unique_key = 'bridge_gpl_id', | ||
incremental_strategy = 'merge' | ||
)}} | ||
|
||
SELECT | ||
{{ dbt_utils.generate_surrogate_key(['game_id','platform_id','released_at']) }} AS bridge_gpl_id, | ||
game_id, | ||
platform_id, | ||
released_at | ||
FROM {{ ref('stg_platforms') }} | ||
{% if is_incremental() %} | ||
WHERE load_date >= (SELECT COALESCE(MAX(load_date), '1900-01-01') FROM {{ this }}) | ||
AND game_id IN (SELECT game_id FROM {{ ref('stg_games') }} WHERE metacritic != 'None') | ||
AND game_id IN (SELECT game_id FROM {{ ref('fct_games') }} WHERE metacritic_score != 'None') | ||
AND released_at != 'NaT' | ||
{% endif %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 6 additions & 3 deletions
9
dags/dbt/games_analyzer_rawg_api/models/bridge/bridge_games_publishers.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,17 @@ | ||
-- depends_on: {{ ref('stg_games') }} | ||
-- depends_on: {{ ref('fct_games') }} | ||
|
||
{{config( | ||
materialized = 'incremental' | ||
materialized = 'incremental', | ||
unique_key = 'bridge_gpu_id', | ||
incremental_strategy = 'merge' | ||
)}} | ||
|
||
SELECT | ||
{{ dbt_utils.generate_surrogate_key(['game_id','publisher_id']) }} AS bridge_gpu_id, | ||
game_id, | ||
publisher_id | ||
FROM {{ ref('stg_publishers') }} | ||
{% if is_incremental() %} | ||
WHERE load_date >= (SELECT COALESCE(MAX(load_date), '1900-01-01') FROM {{ this }}) | ||
AND game_id IN (SELECT game_id FROM {{ ref('stg_games') }} WHERE metacritic != 'None') | ||
AND game_id IN (SELECT game_id FROM {{ ref('fct_games') }} WHERE metacritic_score != 'None') | ||
{% endif %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters