How to convert column of arrays of strings to strings?
<p>I have a column, which is of type <code>array &lt; string &gt;</code> in spark tables. I am using SQL to query these spark tables. I wanted to convert the <code>array &lt; string &gt;</code> into <code>string</code>.</p>

<p>When used the below syntax:</p>

<pre><code>select cast(rate_plan_code  as string) as new_rate_plan  from
customer_activity_searches group by rate_plan_code
</code></pre>

<p><code>rate_plan_code</code> column  has following values:</p>

<pre><code>["AAA","RACK","SMOBIX","SMOBPX"] 
["LPCT","RACK"]
["LFTIN","RACK","SMOBIX","SMOBPX"]
["LTGD","RACK"] 
["RACK","LEARLI","NHDP","LADV","LADV2"]
</code></pre>

<p>following are populated in the <code>new_rate_plan</code> column:</p>

<pre><code>org.apache.spark.sql.catalyst.expressions.UnsafeArrayData@e4273d9f
org.apache.spark.sql.catalyst.expressions.UnsafeArrayData@c1ade2ff
org.apache.spark.sql.catalyst.expressions.UnsafeArrayData@4f378397
org.apache.spark.sql.catalyst.expressions.UnsafeArrayData@d1c81377
org.apache.spark.sql.catalyst.expressions.UnsafeArrayData@552f3317
</code></pre>

<p>Cast seem to work when I am converting <code>decimal</code> to <code>int</code> or <code>int</code> to <code>double</code>, but not in this case. Curious why the cast is not not working here. 
Greatly appreciate your help.</p>