title: spark scala : Convert DataFrame OR Dataset to single comma separated string
body: <p>Below is the spark  scala code which will print one column DataSet[Row]:</p>
  
  <pre><code>import org.apache.spark.sql.{Dataset, Row, SparkSession}
  val spark: SparkSession = SparkSession.builder()
          .appName("Spark DataValidation")
          .config("SPARK_MAJOR_VERSION", "2").enableHiveSupport()
          .getOrCreate()
  
  val kafkaPath:String="hdfs:///landing/APPLICATION/*"
  val targetPath:String="hdfs://datacompare/3"
  val pk:String = "APPLICATION_ID" 
  val pkValues = spark
          .read
          .json(kafkaPath)
          .select("message.data.*")
          .select(pk)
          .distinct() 
  pkValues.show()
  </code></pre>
  
  <p><strong>Output of about code :</strong></p>
  
  <pre><code>+--------------+
  |APPLICATION_ID|
  +--------------+
  |           388|
  |           447|
  |           346|
  |           861|
  |           361|
  |           557|
  |           482|
  |           518|
  |           432|
  |           422|
  |           533|
  |           733|
  |           472|
  |           457|
  |           387|
  |           394|
  |           786|
  |           458|
  +--------------+
  </code></pre>
  
  <p><strong>Question :</strong></p>
  
  <p>How to convert this dataframe to comma separated String variable ?</p>
  
  <p><strong>Expected output :</strong></p>
  
  <pre><code>val   data:String= "388,447,346,861,361,557,482,518,432,422,533,733,472,457,387,394,786,458"
  </code></pre>
  
  <p>Please suggest how to convert DataFrame[Row] or Dataset to one String .</p>