Skip to content

Commit 64bbfab

Browse files
committed
use FileOutputFormat.getTaskOutputPath to get the path
1 parent 8860af0 commit 64bbfab

File tree

1 file changed

+6
-15
lines changed

1 file changed

+6
-15
lines changed

sql/hive/src/main/scala/org/apache/spark/sql/hive/hiveWriterContainers.scala

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ private[hive] class SparkHiveWriterContainer(
6868
@transient private var writer: FileSinkOperator.RecordWriter = null
6969
@transient protected lazy val committer = conf.value.getOutputCommitter
7070
@transient protected lazy val jobContext = newJobContext(conf.value, jID.value)
71-
@transient protected lazy val taskContext = newTaskAttemptContext(conf.value, taID.value)
71+
@transient private lazy val taskContext = newTaskAttemptContext(conf.value, taID.value)
7272
@transient private lazy val outputFormat =
7373
conf.value.getOutputFormat.asInstanceOf[HiveOutputFormat[AnyRef, Writable]]
7474

@@ -227,20 +227,11 @@ private[spark] class SparkHiveDynamicPartitionWriterContainer(
227227
newFileSinkDesc.setCompressCodec(fileSinkConf.getCompressCodec)
228228
newFileSinkDesc.setCompressType(fileSinkConf.getCompressType)
229229

230-
val path = {
231-
val outputPath = FileOutputFormat.getOutputPath(conf.value)
232-
assert(outputPath != null, "Undefined job output-path")
233-
var workPath = outputPath
234-
if(committer.isInstanceOf[FileOutputCommitter]) {
235-
// use the path like $outputPath/_temporary/${attemptId}/
236-
// to avoid write to the same file when `spark.speculation=true`
237-
workPath = committer
238-
.asInstanceOf[FileOutputCommitter]
239-
.getWorkPath(taskContext, outputPath)
240-
}
241-
workPath = new Path(workPath, dynamicPartPath.stripPrefix("/"))
242-
new Path(workPath, getOutputName)
243-
}
230+
// use the path like ${hive_tmp}/_temporary/${attemptId}/
231+
// to avoid write to the same file when `spark.speculation=true`
232+
val path = FileOutputFormat.getTaskOutputPath(
233+
conf.value,
234+
dynamicPartPath.stripPrefix("/") + "/" + getOutputName)
244235

245236
HiveFileFormatUtils.getHiveRecordWriter(
246237
conf.value,

0 commit comments

Comments
 (0)