Comment joindre les deux DataFrames de Scala et Apache Spark?

Il y a deux DataFrames (Scala, Apache Spark 1.6.1)

1) Correspond à

         MatchID | Player1    |  Player2 
         --------------------------------
               1 | John Wayne | John Doe
               2 | Ive Fish   | San Simon

2) Les Données Personnelles

              Player     |  BirthYear 
              --------------------------------
              John Wayne | 1986
              Ive Fish   | 1990
              San Simon  | 1974
              john Doe   | 1995

Comment pourrait créer un nouveau DataFrame avec "Annéenaissance" pour les deux joueurs

         MatchID | Player1    |  Player2  | BYear_P1 |BYear_P2 | Diff
         -------------------------------------------------------------
               1 | John Wayne | John Doe  |   1986   | 1995    |  9  
               2 | Ive Fish   | San Simon |   1990   | 1974    |  16

?

J'ai essayé

    val df = MatchesDF.join(PersonalDF, MatchesDF("Player1") === PersonalDF("Player"))

puis rejoindre à nouveau pour le second joueur

    val resDf = df.join(PersonalDF, df("Player2") === PersonalDF("Player"))

mais c'est TRÈS coûteux en temps de l'opération.

Peut être une autre façon de faire de Scala et Apache Spark?

OriginalL'auteur gmlvsv | 2016-04-22