Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import org.apache.hadoop.hbase.client.TableDescriptor;
import org.apache.hadoop.hbase.client.TableDescriptorBuilder;
import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
import org.apache.hadoop.hbase.regionserver.NoSuchColumnFamilyException;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
import org.apache.hadoop.hbase.util.Pair;
Expand Down Expand Up @@ -554,6 +555,22 @@ protected static Job createSubmittableJob(Configuration conf, String[] args)
LOG.error(errorMsg);
throw new TableNotFoundException(errorMsg);
}
try (Table table = connection.getTable(tableName)) {
ArrayList<String> unmatchedFamilies = new ArrayList<>();
Set<String> cfSet = getColumnFamilies(columns);
TableDescriptor tDesc = table.getDescriptor();
for (String cf : cfSet) {
if (!tDesc.hasColumnFamily(Bytes.toBytes(cf))) {
unmatchedFamilies.add(cf);
}
}
if (unmatchedFamilies.size() > 0) {
String noSuchColumnFamiliesMsg =
format("Column families: %s do not exist.", unmatchedFamilies);
LOG.error(noSuchColumnFamiliesMsg);
throw new NoSuchColumnFamilyException(noSuchColumnFamiliesMsg);
}
}
if (mapperClass.equals(TsvImporterTextMapper.class)) {
usage(TsvImporterTextMapper.class.toString()
+ " should not be used for non bulkloading case. use "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
import org.apache.hadoop.hbase.io.hfile.CacheConfig;
import org.apache.hadoop.hbase.io.hfile.HFile;
import org.apache.hadoop.hbase.io.hfile.HFileScanner;
import org.apache.hadoop.hbase.regionserver.NoSuchColumnFamilyException;
import org.apache.hadoop.hbase.testclassification.LargeTests;
import org.apache.hadoop.hbase.testclassification.VerySlowMapReduceTests;
import org.apache.hadoop.hbase.util.Bytes;
Expand Down Expand Up @@ -241,6 +242,27 @@ public int run(String[] args) throws Exception {
}, args));
}

@Test
public void testMRNoMatchedColumnFamily() throws Exception {
util.createTable(tn, FAMILY);

String[] args = new String[] {
"-D" + ImportTsv.COLUMNS_CONF_KEY
+ "=HBASE_ROW_KEY,FAM:A,FAM01_ERROR:A,FAM01_ERROR:B,FAM02_ERROR:C",
tn.getNameAsString(), "/inputFile" };
exception.expect(NoSuchColumnFamilyException.class);
assertEquals("running test job configuration failed.", 0,
ToolRunner.run(new Configuration(util.getConfiguration()), new ImportTsv() {
@Override
public int run(String[] args) throws Exception {
createSubmittableJob(getConf(), args);
return 0;
}
}, args));

util.deleteTable(tn);
}

@Test
public void testMRWithoutAnExistingTable() throws Exception {
String[] args = new String[] { tn.getNameAsString(), "/inputFile" };
Expand Down