Como associar dois DataFrames no Scala e Apache Spark?
Existem dois DataFrames (Scala, Apache Spark 1.6.1)
1) Partidas
MatchID | Player1 | Player2
--------------------------------
1 | John Wayne | John Doe
2 | Ive Fish | San Simon
2) Dados Pessoais
Player | BirthYear
--------------------------------
John Wayne | 1986
Ive Fish | 1990
San Simon | 1974
john Doe | 1995
Como criar um novo DataFrame com 'BirthYear' para os dois jogadores
MatchID | Player1 | Player2 | BYear_P1 |BYear_P2 | Diff
-------------------------------------------------------------
1 | John Wayne | John Doe | 1986 | 1995 | 9
2 | Ive Fish | San Simon | 1990 | 1974 | 16
?
eu tentei
val df = MatchesDF.join(PersonalDF, MatchesDF("Player1") === PersonalDF("Player"))
então junte-se novamente para o segundo jogador
val resDf = df.join(PersonalDF, df("Player2") === PersonalDF("Player"))
mas é uma operação MUITO demorada.
Pode ser outra maneira de fazer isso no Scala e no Apache Spark?