5
0
mirror of https://github.com/apache/sqoop.git synced 2025-05-16 17:00:53 +08:00

SQOOP-2024: Hive import doesn't remove target directory in hive

(Abraham Elmahrek via Jarek Jarcec Cecho)
This commit is contained in:
Jarek Jarcec Cecho 2015-01-23 17:28:48 -08:00
parent 41d8ca2721
commit 6e555218fb

View File

@ -34,6 +34,7 @@
import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path; import org.apache.hadoop.fs.Path;
import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.mapred.FileOutputCommitter;
import org.apache.hadoop.util.ReflectionUtils; import org.apache.hadoop.util.ReflectionUtils;
import org.apache.hadoop.util.Shell; import org.apache.hadoop.util.Shell;
import org.apache.hadoop.util.ToolRunner; import org.apache.hadoop.util.ToolRunner;
@ -273,6 +274,9 @@ private void cleanUp(Path outputPath) throws IOException {
if (statuses.length == 0) { if (statuses.length == 0) {
LOG.info("Export directory is empty, removing it."); LOG.info("Export directory is empty, removing it.");
fs.delete(outputPath, true); fs.delete(outputPath, true);
} else if (statuses.length == 1 && statuses[0].getPath().getName().equals(FileOutputCommitter.SUCCEEDED_FILE_NAME)) {
LOG.info("Export directory is contains the _SUCCESS file only, removing the directory.");
fs.delete(outputPath, true);
} else { } else {
LOG.info("Export directory is not empty, keeping it."); LOG.info("Export directory is not empty, keeping it.");
} }