-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
migration gamersclub from bronze to silver
- Loading branch information
TeoCalvo
authored and
TeoCalvo
committed
Jan 11, 2024
1 parent
d6e569a
commit 8ff6149
Showing
5 changed files
with
90 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Databricks notebook source | ||
import sys | ||
|
||
sys.path.insert(0, '../../lib') | ||
|
||
import dbtools | ||
|
||
# COMMAND ---------- | ||
|
||
database = "silver.gamersclub" | ||
table_name = dbutils.widgets.get("table_name") | ||
|
||
query = dbtools.import_query(f"sql/{table_name}.sql") | ||
|
||
# COMMAND ---------- | ||
|
||
(spark.sql(query) | ||
.coalesce(1) | ||
.write | ||
.mode("overwrite") | ||
.format("delta") | ||
.option("overwriteSchema", "true") | ||
.saveAsTable(f"{database}.{table_name}") | ||
) |
42 changes: 42 additions & 0 deletions
42
src/03.silver/gamersclub/sql/estatisticas_partidas_jogadores.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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
SELECT | ||
int(idLobbyGame) AS idLobbyJogo, | ||
int(idPlayer) AS idJogador, | ||
int(idRoom) AS idSala, | ||
descMapName AS descNomeMapa, | ||
int(qtKill) AS qtAbates, | ||
int(qtAssist) AS qtdAssistencias, | ||
int(qtDeath) AS qtMortes, | ||
int(qtHs) AS qtHS, | ||
int(qtBombeDefuse) AS qtBombasDesarmadas, | ||
int(qtBombePlant) AS qtBombasArmadas, | ||
int(qtTk) AS qtAbateAmigo, | ||
int(qtTkAssist) AS qtAssistenciaAbateAmigo, | ||
int(qt1Kill) AS qt1AbateRound, | ||
int(qt2Kill) AS qt2AbateRound, | ||
int(qt3Kill) AS qt3AbateRound, | ||
int(qt4Kill) AS qt4AbateRound, | ||
int(qt5Kill) AS qt5AbateRound, | ||
int(qtPlusKill) AS qtMultiplosAbates, | ||
int(qtFirstKill) AS qtPrimeiroAbate, | ||
int(vlDamage) AS vlDano, | ||
int(qtHits) AS qtAcertos, | ||
int(qtShots) AS qtDisparos, | ||
int(qtLastAlive) AS qtUltimoSobrevivente, | ||
int(qtClutchWon) AS qtClutchsVencidos, | ||
int(qtRoundsPlayed) AS qtRoundsJogados, | ||
int(qtSurvived) AS qtRoundVivos, | ||
int(qtTrade) AS qtTrocaAbates, | ||
int(qtFlashAssist) AS qtAssistenciaFlash, | ||
int(qtHitHeadshot) AS qtAcertosCabeca, | ||
int(qtHitChest) AS qtAcertosPeito, | ||
int(qtHitStomach) AS qtAcertosEstomago, | ||
int(qtHitLeftAtm) AS qtAcertosBracoEsquerdo, | ||
int(qtHitRightArm) AS qtAcertosBracoDireito, | ||
int(qtHitLeftLeg) AS qtAcertosPernaEsquerda, | ||
int(qtHitRightLeg) AS qtAcertosPernaDireita, | ||
case when int(flWinner) = 1 then TRUE else FALSE end as flVitoria , | ||
int(vlLevel) AS vlLevel, | ||
timestamp(dtCreatedAt) AS dtPartida | ||
|
||
FROM bronze.gamersclub.tb_lobby_stats_player | ||
|
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
SELECT | ||
int(idPlayer) AS idJogador, | ||
case when int(flFacebook) = 1 then TRUE else FALSE end as flFacebook, | ||
case when int(flTwitter) = 1 then TRUE else FALSE end as flTwitter, | ||
case when int(flTwitch) = 1 then TRUE else FALSE end as flTwitch, | ||
descCountry AS descPais, | ||
date(dtBirth) AS dtNascimento, | ||
timestamp(dtRegistration) AS dtCadastro | ||
|
||
FROM bronze.gamersclub.tb_players |
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
SELECT int(idMedal) AS idMedalha, | ||
descMedal AS descMedalha, | ||
descTypeMedal AS descTipoMedalha | ||
|
||
FROM bronze.gamersclub.tb_medalha |
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
SELECT int(id) AS id, | ||
int(idPlayer) AS idJogador, | ||
int(idMedal) AS idMedalha, | ||
date(dtCreatedAt) AS dtCriacao, | ||
date(dtExpiration) AS dtExpiracao, | ||
date(dtRemove) AS dtRemocao, | ||
int(flActive) AS flAtiva | ||
|
||
FROM bronze.gamersclub.tb_players_medalha |