title: filter only not empty arrays dataframe spark
body: <p>How can i filter only not empty arrays </p>
  
  <pre><code>import  org.apache.spark.sql.types.ArrayType
  
    val arrayFields = secondDF.schema.filter(st =&gt; st.dataType.isInstanceOf[ArrayType])
    val names = arrayFields.map(_.name)
  </code></pre>
  
  <p>Or is this code</p>
  
  <pre><code>val DF1=DF.select(col("key"),explode(col("objectiveAttachment")).as("collection")).select(col("collection.*"),col("key"))
  
  |-- objectiveAttachment: array (nullable = true) 
   | |-- element: string (containsNull = true) 
  </code></pre>
  
  <p>I get this error</p>
  
  <pre><code> org.apache.spark.sql.AnalysisException: Can only star expand struct data types. Attribute: ArrayBuffer(collection);
  </code></pre>
  
  <p>Any help is appreciated.</p>