title: how to check if schema.field.dataype is array of strings in scala with spark
body: <p>This is source code :</p>
  <pre class="lang-scala prettyprint-override"><code>override def createWriter(writeUUID: String, schema: StructType,
                              saveMode: SaveMode, options: DataSourceOptions): Optional[DataSourceWriter] = {
      saveMode match {
        case SaveMode.Append =&gt;
          schema.fields.foreach(field =&gt; {
            if (field.dataType.typeName == &quot;array&quot;) {
  
              throw ArrayDataTypeNotSupportedException(s&quot;${field.name} column is ArrayType, &quot; +
                &quot;writing arrays to CSV isn't supported. Please convert this column to a different data type.&quot;)
  
            }
          })
  
          val sparkSession = SparkSession.active
          val hadoopConf = new SerializableConfiguration(sparkSession.sparkContext.hadoopConfiguration)
  
          val optionsMap = options.asMap()
          val csvOptionsMap = optionsMap.asScala.toMap // convert Java HashMap to Scala Map
          // needed for the UnivocityGenerator
          val csvOptions = new CSVOptions(
            csvOptionsMap,
            columnPruning = sparkSession.sessionState.conf.csvColumnPruning,
            sparkSession.sessionState.conf.sessionLocalTimeZone)
  
  
          Optional.of(new KinesisCSVDataSourceWriter(writeUUID, KinesisCSVDataSourceOptions(csvOptionsMap, schema), csvOptions, hadoopConf))
  
        case _ =&gt; throw UnsupportedSaveModeException(&quot;Only SaveMode.Append is supported&quot;)
      }
    }
  }
  </code></pre>
  <p>and test case is :</p>
  <pre class="lang-scala prettyprint-override"><code>test(&quot;testArrayInSchema&quot;) {
      val df = spark.createDataFrame(Seq(
        TestDataSetArrays(
          Array(1, 2, 3),
          Array(&quot;a&quot;, &quot;b&quot;, &quot;c&quot;),
          Array(new Timestamp(0), new Timestamp(1), new Timestamp(3))
        )
      ))
  
      assertThrows[ArrayDataTypeNotSupportedException] {
        writeDataFrame(df)
      }
    }
  </code></pre>
  <p>Please help how can I check the schema.filed.datatype is a string of array not only array.</p>
  <p>Previously array was not supported but now I want to support an array of strings only and String array should be converted to a comma-separated String.</p>