HBASE-12264 ImportTsv should fail fast if output is not specified and table does not exist (Ashish)

This commit is contained in:
Ted Yu 2014-10-17 20:45:44 +00:00
parent 487b58313c
commit 728fc543ea
2 changed files with 15 additions and 0 deletions

View File

@ -459,6 +459,11 @@ public class ImportTsv extends Configured implements Tool {
}
HFileOutputFormat.configureIncrementalLoad(job, table);
} else {
if (!admin.tableExists(tableName)) {
String errorMsg = format("Table '%s' does not exist.", tableName);
LOG.error(errorMsg);
throw new TableNotFoundException(errorMsg);
}
if (mapperClass.equals(TsvImporterTextMapper.class)) {
usage(TsvImporterTextMapper.class.toString()
+ " should not be used for non bulkloading case. use "

View File

@ -244,6 +244,16 @@ public class TestImportTsv implements Configurable {
ImportTsv.createSubmittableJob(conf, args);
}
@Test(expected = TableNotFoundException.class)
public void testMRWithoutAnExistingTable() throws Exception {
String table = "test-" + UUID.randomUUID();
String[] args =
new String[] { table, "/inputFile" };
Configuration conf = new Configuration(util.getConfiguration());
ImportTsv.createSubmittableJob(conf, args);
}
protected static Tool doMROnTableTest(HBaseTestingUtility util, String family,
String data, String[] args) throws Exception {
return doMROnTableTest(util, family, data, args, 1);