title: Check count of a column from a dataframe and and add column and count as Map
body: <p>I am a scala beginner. I am trying to find count of null values in a column of a table and add column name and count as key value pair in Map. The below code doesn't work as expected. Please guide me how I can modify this code to make it work</p>
  
  <pre><code>def nullCheck(databaseName:String,tableName:String) ={
  var map = scala.collection.mutable.Map[String, Int]() 
  validationColumn = Array(col1,col2)
  for(i &lt;- 0 to validationColumn.length) {
  val nullVal = spark.sql(s"select count(*) from $databaseName.$tableName where validationColumn(i) is NULL")
  if(nullval == 0)
  map(validationColumn(i)) = nullVal
  map
  } 
  </code></pre>
  
  <p>The function should return ((col1,count),(col2,count)) as Map</p>