title: How to join two DataFrames in Scala and Apache Spark?
body: <p>There are two DataFrames (Scala, Apache Spark 1.6.1)</p>
  
  <p>1) Matches</p>
  
  <pre><code>         MatchID | Player1    |  Player2 
           --------------------------------
                 1 | John Wayne | John Doe
                 2 | Ive Fish   | San Simon
  </code></pre>
  
  <p>2) Personal Data</p>
  
  <pre><code>              Player     |  BirthYear 
                --------------------------------
                John Wayne | 1986
                Ive Fish   | 1990
                San Simon  | 1974
                john Doe   | 1995
  </code></pre>
  
  <p>How could create a new DataFrame with 'BirthYear' for the both players</p>
  
  <pre><code>         MatchID | Player1    |  Player2  | BYear_P1 |BYear_P2 | Diff
           -------------------------------------------------------------
                 1 | John Wayne | John Doe  |   1986   | 1995    |  9  
                 2 | Ive Fish   | San Simon |   1990   | 1974    |  16
  </code></pre>
  
  <p>?</p>
  
  <p>I tried </p>
  
  <pre><code>    val df = MatchesDF.join(PersonalDF, MatchesDF("Player1") === PersonalDF("Player"))
  </code></pre>
  
  <p>then join again for the second player</p>
  
  <pre><code>    val resDf = df.join(PersonalDF, df("Player2") === PersonalDF("Player"))
  </code></pre>
  
  <p>but it's VERY time consuming operation.</p>
  
  <p>May be another way to do it in Scala and Apache Spark?</p>