title: Spark - How to apply rules defined in a dataframe to another dataframe
body: <p>I'm trying to solve this kind of problem with Spark 2, but I can't find a solution.</p>
  
  <p>I have a <strong>dataframe A</strong> :</p>
  
  <pre class="lang-none prettyprint-override"><code>+----+-------+------+
  |id  |COUNTRY| MONTH|
  +----+-------+------+
  |  1 |    US |    1 |
  |  2 |    FR |    1 |
  |  4 |    DE |    1 |
  |  5 |    DE |    2 |
  |  3 |    DE |    3 |
  +----+-------+------+
  </code></pre>
  
  <p>And a <strong>dataframe B</strong> :</p>
  
  <pre class="lang-none prettyprint-override"><code>+-------+------+------+
  |COLUMN |VALUE | PRIO |
  +-------+------+------+
  |COUNTRY|   US |    5 |
  |COUNTRY|   FR |   15 |
  |MONTH  |   3  |    2 |
  +-------+------+------+
  </code></pre>
  
  <p>The idea is to apply "rules" of dataframe B on dataframe A in order to get this result :</p>
  
  <p><strong>dataframe A'</strong> :</p>
  
  <pre class="lang-none prettyprint-override"><code>+----+-------+------+------+
  |id  |COUNTRY| MONTH| PRIO |
  +----+-------+------+------+
  |  1 |    US |    1 |    5 |
  |  2 |    FR |    1 |   15 |
  |  4 |    DE |    1 |   20 |
  |  5 |    DE |    2 |   20 |
  |  3 |    DE |    3 |    2 |
  +----+-------+------+------+
  </code></pre>
  
  <p>I tried someting like that :</p>
  
  <pre><code>dfB.collect.foreach( r =&gt;
      var dfAp = dfA.where(r.getAs("COLUMN") == r.getAs("VALUE"))
      dfAp.withColumn("PRIO", lit(r.getAs("PRIO")))
  )
  </code></pre>
  
  <p>But I'm sure it's not the right way.</p>
  
  <p>What are the strategy to solve this problem in Spark ?</p>