title: how do I loop a array in udf and return multiple variable value
body: <p>I'm fresh with scala and udf, now I would like to write a udf which accept 3 parameters from a dataframe columns(one of them is array), for..loop current array, parse and return a case class which will be used afterwards. here's a my code roughly:</p>
  <pre><code>case class NewFeatures(dd: Boolean, zz: String)    
  val resultUdf = udf((arrays: Option[Row], jsonData: String, placement: Int) =&gt; {
        for (item &lt;- arrays) {
          val aa = item.getAs[Long](&quot;aa&quot;)
          val bb = item.getAs[Long](&quot;bb&quot;)
          breakable {
            if (aa &lt;= 0 || bb &lt;= 0) break
          }
          val cc = item.getAs[Long](&quot;cc&quot;)
          val dd = cc &gt; 0
  
          val jsonData = item.getAs[String](&quot;json_data&quot;)
          val jsonDataObject = JSON.parseFull(jsonData).asInstanceOf[Map[String, Any]]
          var zz = jsonDataObject.getOrElse(&quot;zz&quot;, &quot;&quot;).toString
          NewFeatures(dd, zz)
  
        }
        
  
      })
  </code></pre>
  <p>when I run it, it will get exception:</p>
  <pre><code>java.lang.UnsupportedOperationException: Schema for type Unit is not supported
  </code></pre>
  <p>how should I modify above udf</p>