title: Build Spark SQL query dynamically
body: <p>How we can pass a column name and operator name dynamically to the SQL query with Spark in Scala?</p>
  
  <p>I tried (unsuccessfully) the following:</p>
  
  <pre><code>spark.sql("set key_tbl=mytable")
  spark.sql("select count(1) from ${key_tbl}").collect()
  </code></pre>