title: How to build a dynamic query string to execute on a spark-sql 2.3.1 dataframe?
body: <p>I have a requirement to get the where condition passed by user as program arguments. Based on the where condition i need to query the source data base.</p>
  
  <p>I am using spark-sql.2.3.1
  How to construct and pass/executive dynamically build query?</p>
  
  <p>Sample query:</p>
  
  <pre><code>select ProductId, COUNT(*) AS ProductSaleCount
   from productsale
   where to_date(Date) &gt;= "2015-12-17"
   and to_date(Date) &lt;= "2015-12-31"
   group by ProductId
  </code></pre>