title: How to write case class for varying no of columns for DataFrames
body: <p>How to write a case class dynamically for varying number of columns, data-type of the columns can be String.</p>
  
  <p>Now I'm using RDD without any schema but I would like to use dataframes which needs schema.</p>
  
  <p>Code Im using to fetch Headers from Databases</p>
  
  <pre><code>  var options = Map(
      "url" -&gt; url,
      "driver" -&gt; databaseRead.split(",")(4),
      "dbtable" -&gt; databaseRead.split(",")(2),
      "user" -&gt; databaseRead.split(",")(5),
      "password" -&gt; databaseRead.split(",")(6))
  
  
   val fieldname = spark.read.options(options).jdbc(options("url"), options("dbtable"), new java.util.Properties()).schema.fieldNames.toArray
  </code></pre>