HCATALOG-584 Changes in HCAT-538 break Pig stores into non-partitioned tables


git-svn-id: https://svn.apache.org/repos/asf/incubator/hcatalog/trunk@1427208 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/CHANGES.txt b/CHANGES.txt
index e30a5c6..657f377 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -168,6 +168,8 @@
   OPTIMIZATIONS
 
   BUG FIXES
+  HCAT-584 Changes in HCAT-538 break Pig stores into non-partitioned tables (gates)
+
   HCAT-576 HCATALOG-527 Broke backward compatibility (gates)
 
   HCAT-567 HCatClient must allow retrieval of multiple partitions using a partial partition spec.(mithun via avandana)
diff --git a/core/src/main/java/org/apache/hcatalog/mapreduce/FileOutputCommitterContainer.java b/core/src/main/java/org/apache/hcatalog/mapreduce/FileOutputCommitterContainer.java
index 4149307..4bce2b1 100644
--- a/core/src/main/java/org/apache/hcatalog/mapreduce/FileOutputCommitterContainer.java
+++ b/core/src/main/java/org/apache/hcatalog/mapreduce/FileOutputCommitterContainer.java
@@ -420,6 +420,9 @@
                 if(LOG.isDebugEnabled()) {
                     LOG.debug("Moving file: [ " + file + "] to [" + finalOutputPath + "]");
                 }
+                // Make sure the parent directory exists.  It is not an error
+                // to recreate an existing directory
+                fs.mkdirs(finalOutputPath.getParent());
                 if (!fs.rename(file, finalOutputPath)) {
                     if (!fs.delete(finalOutputPath, true)) {
                         throw new HCatException(ErrorType.ERROR_MOVE_FAILED, "Failed to delete existing path " + finalOutputPath);