diff --git a/src/03.silver/dota/feature_store/etl/players_hero.sql b/src/03.silver/dota/feature_store/etl/players_hero.sql new file mode 100644 index 0000000..f6b55d2 --- /dev/null +++ b/src/03.silver/dota/feature_store/etl/players_hero.sql @@ -0,0 +1,39 @@ +WITH tb_matches_players AS ( + SELECT + * + FROM silver.dota.matches_players + WHERE dtMatch >= '{date}' - INTERVAL {window} DAY + AND dtMatch < '{date}' +), + +tb_players_hero AS ( + SELECT + '{date}' AS dtReference, + idPlayer, + idHero, + count(distinct idMatch) AS nrFreqPlayerHero, + avg(flWin) AS pctWinRatePlayerHero, + avg(nrGoldMinute) AS nrGoldMinutePlayerHero, + avg(nrXpMinute) AS nrXpMinutePlayerHero + FROM tb_matches_players + GROUP BY dtReference, idPlayer, idHero +), + +tb_hero AS ( + SELECT idHero, + avg(flWin) AS pctWinRateHero, + avg(nrGoldMinute) AS nrGoldMinuteHero, + avg(nrXpMinute) AS nrXpMinuteHero + FROM tb_matches_players + GROUP BY idHero +) + +SELECT t1.*, + t1.pctWinRatePlayerHero / t2.pctWinRateHero AS pctRateWinRatePlayerHero, + t1.nrGoldMinutePlayerHero / t2.nrGoldMinuteHero AS pctRateGoldMinutePlayerHero, + t1.nrXpMinutePlayerHero / t2.nrXpMinuteHero AS pctRateXpMinutePlayerHero + +FROM tb_players_hero AS t1 + +LEFT JOIN tb_hero AS t2 +ON t1.idHero = t2.idHero \ No newline at end of file diff --git a/src/06.workflows/data4u_dota.json b/src/06.workflows/data4u_dota.json index 53d63b2..9d83bc3 100644 --- a/src/06.workflows/data4u_dota.json +++ b/src/06.workflows/data4u_dota.json @@ -189,6 +189,81 @@ "existing_cluster_id": "0809-155233-nc569ju7", "timeout_seconds": 0, "email_notifications": {} + }, + { + "task_key": "fs_players_hero_30", + "depends_on": [ + { + "task_key": "silver_matches_players" + } + ], + "notebook_task": { + "notebook_path": "src/03.silver/dota/feature_store/fs_ingestao", + "base_parameters": { + "table": "players_hero", + "window": "30", + "description": "Feature Store de jogadores profissionais com suas estatísticas sumarizadas em nível de herói (D30)", + "id_fields": "dtReference,idPlayer,idHero", + "partition_fields": "dtReference", + "date_start": "{{start_date}}", + "date_stop": "{{start_date}}", + "monthly": "False" + }, + "source": "GIT" + }, + "existing_cluster_id": "0809-155233-nc569ju7", + "timeout_seconds": 0, + "email_notifications": {} + }, + { + "task_key": "fs_players_hero_90", + "depends_on": [ + { + "task_key": "silver_matches_players" + } + ], + "notebook_task": { + "notebook_path": "src/03.silver/dota/feature_store/fs_ingestao", + "base_parameters": { + "table": "players_hero", + "window": "90", + "description": "Feature Store de jogadores profissionais com suas estatísticas sumarizadas em nível de herói (D90)", + "id_fields": "dtReference,idPlayer,idHero", + "partition_fields": "dtReference", + "date_start": "{{start_date}}", + "date_stop": "{{start_date}}", + "monthly": "False" + }, + "source": "GIT" + }, + "existing_cluster_id": "0809-155233-nc569ju7", + "timeout_seconds": 0, + "email_notifications": {} + }, + { + "task_key": "fs_players_hero_180", + "depends_on": [ + { + "task_key": "silver_matches_players" + } + ], + "notebook_task": { + "notebook_path": "src/03.silver/dota/feature_store/fs_ingestao", + "base_parameters": { + "table": "players_hero", + "window": "180", + "description": "Feature Store de jogadores profissionais com suas estatísticas sumarizadas em nível de herói (D180)", + "id_fields": "dtReference,idPlayer,idHero", + "partition_fields": "dtReference", + "date_start": "{{start_date}}", + "date_stop": "{{start_date}}", + "monthly": "False" + }, + "source": "GIT" + }, + "existing_cluster_id": "0809-155233-nc569ju7", + "timeout_seconds": 0, + "email_notifications": {} } ], "git_source": {