diff --git a/ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java b/ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java index 2fe86e1..a27038b 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java @@ -2215,7 +2215,7 @@ static protected boolean renameFile(HiveConf conf, Path srcf, Path destf, FileSy } } success = fs.rename(srcf, destf); - LOG.debug((replace ? "Replacing src:" : "Renaming src:") + srcf.toString() + LOG.info((replace ? "Replacing src:" : "Renaming src:") + srcf.toString() + ";dest: " + destf.toString() + ";Status:" + success); } catch (IOException ioe) { throw new HiveException("Unable to move source" + srcf + " to destination " + destf, ioe); @@ -2317,10 +2317,7 @@ static protected void replaceFiles(Path srcf, Path destf, Path oldPath, HiveConf } List> result = checkPaths(conf, fs, srcs, destf, true); - // point of no return -- delete oldPath only if it is not same as destf, - // otherwise, the oldPath/destf will be cleaned later just before move - if (oldPath != null && (!destf.getFileSystem(conf).equals(oldPath.getFileSystem(conf)) - || !destf.equals(oldPath))) { + if (oldPath != null) { try { FileSystem fs2 = oldPath.getFileSystem(conf); if (fs2.exists(oldPath)) { @@ -2341,6 +2338,9 @@ static protected void replaceFiles(Path srcf, Path destf, Path oldPath, HiveConf Path destfp = destf.getParent(); if (!fs.exists(destfp)) { boolean success = fs.mkdirs(destfp); + if (!success) { + LOG.warn("Error creating directory " + destf.toString()); + } if (inheritPerms && success) { fs.setPermission(destfp, fs.getFileStatus(destfp.getParent()).getPermission()); } @@ -2354,6 +2354,9 @@ static protected void replaceFiles(Path srcf, Path destf, Path oldPath, HiveConf } else { // srcf is a file or pattern containing wildcards if (!fs.exists(destf)) { boolean success = fs.mkdirs(destf); + if (!success) { + LOG.warn("Error creating directory " + destf.toString()); + } if (inheritPerms && success) { fs.setPermission(destf, fs.getFileStatus(destf.getParent()).getPermission()); } diff --git a/ql/src/test/queries/clientpositive/load_fs_overwrite.q b/ql/src/test/queries/clientpositive/load_fs_overwrite.q new file mode 100644 index 0000000..51a8031 --- /dev/null +++ b/ql/src/test/queries/clientpositive/load_fs_overwrite.q @@ -0,0 +1,20 @@ +--HIVE 6209 + +drop table target; +drop table temp; + +create table target (key string, value string) stored as textfile location 'file:${system:test.tmp.dir}/target'; +create table temp (key string, value string) stored as textfile location 'file:${system:test.tmp.dir}/temp'; + +set fs.pfile.impl.disable.cache=false; + +load data local inpath '../../data/files/kv1.txt' into table temp; +load data inpath '${system:test.tmp.dir}/temp/kv1.txt' overwrite into table target; +select count(*) from target; + +load data local inpath '../../data/files/kv2.txt' into table temp; +load data inpath '${system:test.tmp.dir}/temp/kv2.txt' overwrite into table target; +select count(*) from target; + +drop table target; +drop table temp; \ No newline at end of file diff --git a/ql/src/test/results/clientpositive/load_fs_overwrite.q.out b/ql/src/test/results/clientpositive/load_fs_overwrite.q.out new file mode 100644 index 0000000..61fa07c --- /dev/null +++ b/ql/src/test/results/clientpositive/load_fs_overwrite.q.out @@ -0,0 +1,80 @@ +PREHOOK: query: --HIVE 6209 + +drop table target +PREHOOK: type: DROPTABLE +POSTHOOK: query: --HIVE 6209 + +drop table target +POSTHOOK: type: DROPTABLE +PREHOOK: query: drop table temp +PREHOOK: type: DROPTABLE +POSTHOOK: query: drop table temp +POSTHOOK: type: DROPTABLE +#### A masked pattern was here #### +PREHOOK: type: CREATETABLE +#### A masked pattern was here #### +POSTHOOK: type: CREATETABLE +POSTHOOK: Output: default@target +#### A masked pattern was here #### +PREHOOK: type: CREATETABLE +#### A masked pattern was here #### +POSTHOOK: type: CREATETABLE +POSTHOOK: Output: default@temp +PREHOOK: query: load data local inpath '../../data/files/kv1.txt' into table temp +PREHOOK: type: LOAD +PREHOOK: Output: default@temp +POSTHOOK: query: load data local inpath '../../data/files/kv1.txt' into table temp +POSTHOOK: type: LOAD +POSTHOOK: Output: default@temp +#### A masked pattern was here #### +PREHOOK: type: LOAD +PREHOOK: Output: default@target +#### A masked pattern was here #### +POSTHOOK: type: LOAD +POSTHOOK: Output: default@target +PREHOOK: query: select count(*) from target +PREHOOK: type: QUERY +PREHOOK: Input: default@target +#### A masked pattern was here #### +POSTHOOK: query: select count(*) from target +POSTHOOK: type: QUERY +POSTHOOK: Input: default@target +#### A masked pattern was here #### +500 +PREHOOK: query: load data local inpath '../../data/files/kv2.txt' into table temp +PREHOOK: type: LOAD +PREHOOK: Output: default@temp +POSTHOOK: query: load data local inpath '../../data/files/kv2.txt' into table temp +POSTHOOK: type: LOAD +POSTHOOK: Output: default@temp +#### A masked pattern was here #### +PREHOOK: type: LOAD +PREHOOK: Output: default@target +#### A masked pattern was here #### +POSTHOOK: type: LOAD +POSTHOOK: Output: default@target +PREHOOK: query: select count(*) from target +PREHOOK: type: QUERY +PREHOOK: Input: default@target +#### A masked pattern was here #### +POSTHOOK: query: select count(*) from target +POSTHOOK: type: QUERY +POSTHOOK: Input: default@target +#### A masked pattern was here #### +500 +PREHOOK: query: drop table target +PREHOOK: type: DROPTABLE +PREHOOK: Input: default@target +PREHOOK: Output: default@target +POSTHOOK: query: drop table target +POSTHOOK: type: DROPTABLE +POSTHOOK: Input: default@target +POSTHOOK: Output: default@target +PREHOOK: query: drop table temp +PREHOOK: type: DROPTABLE +PREHOOK: Input: default@temp +PREHOOK: Output: default@temp +POSTHOOK: query: drop table temp +POSTHOOK: type: DROPTABLE +POSTHOOK: Input: default@temp +POSTHOOK: Output: default@temp