title: Spark SQL - Get Column Names of a Hive Table in a String
body: <p>I'm trying to get the column names of a Hive table in a comma separated String. This is what I'm doing</p>
  <pre><code>val colNameDF = spark.sql(&quot;show columns in hive_table&quot;)
  val colNameStr = colNameDF.select(&quot;col_name&quot;).collect.mkString(&quot;, &quot;)
  </code></pre>
  <p>And the output I get is</p>
  <pre><code>res0: String = [col_1], [col_2], [col_3]
  </code></pre>
  <p>But what I want is <code>col_1, col_2, col_3</code>. I can remove <code>[</code> and <code>]</code> from the String, but I'm curious as to whether we can get the column names without the brackets in the first place.</p>
  <p><strong>Edit:</strong> The column names in the Hive table don't contain [ ]</p>