Skip to content

Commit 871c3ee

Browse files
authored
Merge pull request apache#595 from mapr/SPARK-638
MapR [SPARK-638] Wrong permissions when creating files under directory
2 parents c99e9c9 + 1a6ff6f commit 871c3ee

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/FileFormatDataWriter.scala

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,16 @@ class DynamicPartitionDataWriter(
233233
committer.newTaskTempFile(taskAttemptContext, partDir, ext)
234234
}
235235

236+
// Creation of intermediate folders with mkdirs() required because
237+
// intermediate folders created by create() don't inherit permission bits
238+
// https://maprdrill.atlassian.net/browse/SPARK-638
239+
def createIntermediateFolder(filePath: String, taskAttemptContext: TaskAttemptContext) {
240+
val folderPath = new Path(filePath).getParent
241+
val fileSystem = folderPath.getFileSystem(taskAttemptContext.getConfiguration)
242+
fileSystem.mkdirs(folderPath)
243+
}
244+
createIntermediateFolder(currentPath, taskAttemptContext)
245+
236246
currentWriter = description.outputWriterFactory.newInstance(
237247
path = currentPath,
238248
dataSchema = description.dataColumns.toStructType,

0 commit comments

Comments
 (0)