You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "ykisana (via GitHub)" <gi...@apache.org> on 2026/10/10 02:41:07 UTC
[PR] [SPARK-60023][SQL] Set writeJobUUID before setupJob in FileFormatWriter [spark]
ykisana opened a new pull request, #59333:
URL: https://github.com/apache/spark/pull/59333
### What changes were proposed in this pull request?
In `FileFormatWriter.write`, set `spark.sql.sources.writeJobUUID` on the job configuration before `committer.setupJob(job)` instead of after `materializeAdaptiveSparkPlan`, inside the `try` block.
SPARK-56919 moved `committer.setupJob(job)` ahead of `materializeAdaptiveSparkPlan(plan)` so that an AQE failure calls `committer.abortJob(job)` instead of losing the output path. The `writeJobUUID` assignment stayed where it was, so committers now run `setupJob` (and `abortJob`, if materialization fails) before the UUID is set. This PR restores the pre-SPARK-56919 order: set the UUID, then call `setupJob`. `SparkHadoopWriter` uses the same order for the RDD write path. `description.uuid` is already available at that point, and the value is unchanged.
### Why are the changes needed?
Committers that read `spark.sql.sources.writeJobUUID` in `setupJob` or `abortJob` fall back to `jobContext.getJobID()` when it is not set. That job ID is null for the `Job` that `FileFormatWriter` creates, because the job is never submitted. Hadoop's `ManifestCommitter`, the default committer for `gs://` and `abfs://` since Hadoop 3.4, fails every file source write with:
```
java.lang.NullPointerException: Cannot invoke "org.apache.hadoop.mapreduce.JobID.toString()" because "jobId" is null
at org.apache.hadoop.mapreduce.lib.output.committer.manifest.impl.ManifestCommitterSupport.buildJobUUID(ManifestCommitterSupport.java:118)
at org.apache.hadoop.mapreduce.lib.output.committer.manifest.ManifestCommitterConfig.<init>(ManifestCommitterConfig.java:190)
at org.apache.hadoop.mapreduce.lib.output.committer.manifest.ManifestCommitter.enterCommitter(ManifestCommitter.java:181)
at org.apache.hadoop.mapreduce.lib.output.committer.manifest.ManifestCommitter.setupJob(ManifestCommitter.java:196)
at org.apache.spark.internal.io.HadoopMapReduceCommitProtocol.setupJob(HadoopMapReduceCommitProtocol.scala:198)
at org.apache.spark.sql.execution.datasources.FileFormatWriter$.write(FileFormatWriter.scala:165)
```
### Does this PR introduce _any_ user-facing change?
Yes, a bug fix. SPARK-56919 shipped in Spark 4.2.0, and since then file source writes (`DataFrameWriter`, `INSERT`, Hive `INSERT` and the file streaming sink) fail with the `NullPointerException` above when the output committer reads `spark.sql.sources.writeJobUUID` during job setup, e.g. `ManifestCommitter`. After this change, these writes succeed as they did before 4.2.0.
### How was this patch tested?
Added a test, `SPARK-60023: writeJobUUID should be set before setupJob`, to `FileFormatWriterSuite`. It sets `spark.sql.sources.commitProtocolClass` to a test `SQLHadoopMapReduceCommitProtocol` subclass whose `setupJob` asserts that `spark.sql.sources.writeJobUUID` is set, then writes and reads back a parquet file.
```
build/sbt 'sql/testOnly *FileFormatWriterSuite -- -z "SPARK-60023"'
```
- With this change, both the codegen and interpreted variants pass.
- Without the change in `FileFormatWriter.scala`, both fail with `assertion failed: spark.sql.sources.writeJobUUID should be set before setupJob`.
`build/sbt sql/scalastyle sql/Test/scalastyle` also passes.
### Was this patch authored or co-authored using generative AI tooling?
Generated by: Claude Opus 5.5
Fix written by and all code manually reviewed by @ykisana.
Tests, PR description, and comments by Claude.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-60023][SQL] Set writeJobUUID before setupJob in FileFormatWriter [spark]
Posted by "szehon-ho (via GitHub)" <gi...@apache.org>.
szehon-ho commented on PR #59333:
URL: https://github.com/apache/spark/pull/59333#issuecomment-6275056949
Thank you!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-60023][SQL] Set writeJobUUID before setupJob in FileFormatWriter [spark]
Posted by "cloud-fan (via GitHub)" <gi...@apache.org>.
cloud-fan commented on PR #59333:
URL: https://github.com/apache/spark/pull/59333#issuecomment-6210825735
Agreed, the fix looks right to me. Before SPARK-56919, FileFormatWriter set spark.sql.sources.writeJobUUID before writeAndCommit called setupJob. SPARK-56919 moved setupJob ahead of materializeAdaptiveSparkPlan but left the UUID assignment inside the try. Since then, setupJob (and abortJob after a materialization failure) runs without the key. This PR moves the assignment back ahead of setupJob, the same order SparkHadoopWriter uses, and the value is still description.uuid. On severity: in Hadoop 3.5.0, which Spark builds against, mapred-default.xml maps abfs and gs to the manifest committer factories, and ManifestCommitter derives its job UUID from this key in setupJob. So in 4.2.0, file writes to abfs:// or gs:// that use the scheme's default Hadoop committer fail at setupJob. Parquet's default ParquetOutputCommitter and the streaming sink's default ManifestFileCommitProtocol don't read the key, so not every write is affected, but this is still a common cloud path. SPARK-56919 i
s on branch-4.2, branch-4.3 and branch-4.x, so this fix should be backported to the same branches.
<!-- SPARK_DEV_REVIEW_REPLY {"feedback_id":"conversation:6159560585","thread_id":"conversation:6159560585","verdict_sha256":"94a57059c643b0b8a0e34e070ad814bdc72a190f9c60952a1c723c442a67e310"} -->
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-60023][SQL] Set writeJobUUID before setupJob in FileFormatWriter [spark]
Posted by "pan3793 (via GitHub)" <gi...@apache.org>.
pan3793 closed pull request #59333: [SPARK-60023][SQL] Set writeJobUUID before setupJob in FileFormatWriter
URL: https://github.com/apache/spark/pull/59333
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-60023][SQL] Set writeJobUUID before setupJob in FileFormatWriter [spark]
Posted by "pan3793 (via GitHub)" <gi...@apache.org>.
pan3793 commented on PR #59333:
URL: https://github.com/apache/spark/pull/59333#issuecomment-6259139071
cc @HeartSaVioR and @szehon-ho, I just merged this to branch-4.3 and branch-4.2, so it will be included in the next RC of 4.3.0 and 4.2.1
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-60023][SQL] Set writeJobUUID before setupJob in FileFormatWriter [spark]
Posted by "pan3793 (via GitHub)" <gi...@apache.org>.
pan3793 commented on PR #59333:
URL: https://github.com/apache/spark/pull/59333#issuecomment-6159560585
The fix looks correct to me, and this seems to be a serious issue for Microsoft ABFS and Google GS users.
cc @shrirangmhalgi @cloud-fan, could you take a look and evaluate the severity?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-60023][SQL] Set writeJobUUID before setupJob in FileFormatWriter [spark]
Posted by "uros-b (via GitHub)" <gi...@apache.org>.
uros-b commented on PR #59333:
URL: https://github.com/apache/spark/pull/59333#issuecomment-6286210022
Thank you for catching this and following up on it @dongjoon-hyun!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-60023][SQL] Set writeJobUUID before setupJob in FileFormatWriter [spark]
Posted by "pan3793 (via GitHub)" <gi...@apache.org>.
pan3793 commented on PR #59333:
URL: https://github.com/apache/spark/pull/59333#issuecomment-6259074304
**Merge Summary:**
- merged into master https://github.com/apache/spark/commit/0ac411160c03b761fabdc94893965f6225b87e72
- merged into branch-4.x https://github.com/apache/spark/commit/19c0e29c89ad3d0a7e7581ecf3d7eb9bddde6c4c
- merged into branch-4.3 https://github.com/apache/spark/commit/dd8bf948ffac519118aac62bcc8bffbbb10571e1
- merged into branch-4.2 https://github.com/apache/spark/commit/0b69ff03f3fc903e01c1d057a1af4004cae52957
*Posted by `merge_spark_pr.py`*
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org