title: dataframe with dynamic when condition using with column
body: <p>I have a Scala code for computing a new column with using withcolumn function in my hardcoded code which looks something like this </p>
  
  <pre><code> combinedinputdf
    .withColumn("AMGClassRule", when(col("CoreSectorLevel1Code") === "Derivatives" &amp;&amp; col("CoreSectorLevel2Code") === "Caps" &amp;&amp; col("FAS157Flavor") === "SPRD", "1")
        //.when(col("CoreSectorLevel1Code") === "Derivatives" &amp;&amp; col("CoreSectorLevel2Code") === "Caps" &amp;&amp; col("FAS157Flavor") === "SPRD", "2")
        .when(col("CoreSectorLevel1Code") === "Derivatives" &amp;&amp; col("FAS157Flavor") === "TRSY" &amp;&amp; col("DerivativeType") === "TROR", "3")
        .when(col("InDefaultInd") === "Y" , "4")
  </code></pre>
  
  <p>This works as expected.</p>
  
  <p>But I want to dynamically add or modify the when condition while executing  based on table or CSV</p>
  
  <p>second table looks like this <a href="https://i.stack.imgur.com/JyLy1.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JyLy1.jpg" alt="Tables with rules"></a></p>
  
  <p>so at runtime I can read this table into either dataframe or Map and iterate through rules of the table and assign a value to my output</p>
  
  <p>How do I go about doing this dynamically?</p>