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

    https://github.com/apache/spark/pull/12855#discussion_r61863832
  
    --- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/WriterContainer.scala
 ---
    @@ -239,48 +239,50 @@ private[sql] class DefaultWriterContainer(
       extends BaseWriterContainer(relation, job, isAppend) {
     
       def writeRows(taskContext: TaskContext, iterator: 
Iterator[InternalRow]): Unit = {
    -    executorSideSetup(taskContext)
    -    val configuration = taskAttemptContext.getConfiguration
    -    configuration.set("spark.sql.sources.output.path", outputPath)
    -    var writer = newOutputWriter(getWorkPath)
    -    writer.initConverter(dataSchema)
    -
    -    // If anything below fails, we should abort the task.
    -    try {
    -      Utils.tryWithSafeFinallyAndFailureCallbacks {
    -        while (iterator.hasNext) {
    -          val internalRow = iterator.next()
    -          writer.writeInternal(internalRow)
    -        }
    -        commitTask()
    -      }(catchBlock = abortTask())
    -    } catch {
    -      case t: Throwable =>
    -        throw new SparkException("Task failed while writing rows", t)
    -    }
    +    if (iterator.hasNext) {
    --- End diff --
    
    Simply added `iterator.hasNext` check.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to