title: filter spark dataframe based on maximum value of a column
body: <p>I want to do something like this:</p>
  
  <pre><code>df
  .withColumn("newCol", &lt;some formula&gt;)
  .filter(s"""newCol &gt; ${(math.min(max("newCol").asInstanceOf[Double],10))}""")
  </code></pre>
  
  <p>Exception I'm getting:</p>
  
  <pre><code>org.apache.spark.sql.Column cannot be cast to java.lang.Double
  </code></pre>
  
  <p>Can you please suggest me a way to achieve what i want?</p>