fix CTAS failures when using viewfs
@@ -419,8 +419,14 @@ public final class HiveWriteUtils
// use relative temporary directory on ViewFS
if (isViewFileSystem(context, hdfsEnvironment, targetPath)) {
+ if (pathExists(context, hdfsEnvironment, targetPath)) {
temporaryPrefix = ".hive-staging";
}
+ else {
+ //use the temporary folder in parent when target path does not exist
+ temporaryPrefix = "../.hive-staging";
+ }
+ }
// create a temporary directory on the same filesystem
Path temporaryRoot = new Path(targetPath, temporaryPrefix);
