Github user HyukjinKwon commented on a diff in the pull request:

    https://github.com/apache/spark/pull/23052#discussion_r234062564
  
    --- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/csv/CSVFileFormat.scala
 ---
    @@ -174,13 +174,18 @@ private[csv] class CsvOutputWriter(
         context: TaskAttemptContext,
         params: CSVOptions) extends OutputWriter with Logging {
     
    -  private val charset = Charset.forName(params.charset)
    +  private var univocityGenerator: Option[UnivocityGenerator] = None
     
    -  private val writer = CodecStreams.createOutputStreamWriter(context, new 
Path(path), charset)
    -
    -  private val gen = new UnivocityGenerator(dataSchema, writer, params)
    +  override def write(row: InternalRow): Unit = {
    +    val gen = univocityGenerator.getOrElse {
    --- End diff --
    
    Also, one thing we should not forget about is, CSV _could_ have headers 
even if the records are empty.


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to