Github user gatorsmile commented on a diff in the pull request:
https://github.com/apache/spark/pull/16104#discussion_r90740642
--- Diff:
sql/hive/src/main/scala/org/apache/spark/sql/hive/execution/InsertIntoHiveTable.scala
---
@@ -121,21 +121,61 @@ case class InsertIntoHiveTable(
return dir
}
- private def getExternalScratchDir(extURI: URI, hadoopConf:
Configuration): Path = {
- getStagingDir(new Path(extURI.getScheme, extURI.getAuthority,
extURI.getPath), hadoopConf)
+ private def getExternalScratchDir(extURI: URI): Path = {
+ getStagingDir(new Path(extURI.getScheme, extURI.getAuthority,
extURI.getPath))
}
- def getExternalTmpPath(path: Path, hadoopConf: Configuration): Path = {
+ def getExternalTmpPath(path: Path): Path = {
+ val hiveVersion =
externalCatalog.asInstanceOf[HiveExternalCatalog].client.version.fullVersion
+ if (hiveVersion.startsWith("0.12") ||
+ hiveVersion.startsWith("0.13") ||
+ hiveVersion.startsWith("0.14") ||
+ hiveVersion.startsWith("1.0")) {
+ oldStyleExternalTempPath(path)
+ } else if (hiveVersion.startsWith("1.1") ||
hiveVersion.startsWith("1.2")) {
+ newStyleExternalTempPath(path)
+ } else {
+ throw new IllegalStateException("Unsupported hive version: " +
hiveVersion)
+ }
+ }
+
+ // Mostly copied from Context.java#getExternalTmpPath of Hive 0.13
+ def oldStyleExternalTempPath(path: Path): Path = {
+ val extURI: URI = path.toUri
+ val scratchPath = new Path(scratchDir, executionId)
+ var dirPath = new Path(
+ extURI.getScheme,
+ extURI.getAuthority,
+ scratchPath.toUri.getPath + "-" + TaskRunner.getTaskRunnerID())
+
+ try {
+ val fs: FileSystem = dirPath.getFileSystem(hadoopConf)
+ dirPath = new Path(fs.makeQualified(dirPath).toString())
+
+ if (!FileUtils.mkdir(fs, dirPath, true, hadoopConf)) {
--- End diff --
Keeping these useless directories and files might not make sense, right?
Many many files could accumulate?
---
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]