Index: src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java =================================================================== --- src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java (revision 1197263) +++ src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java (working copy) @@ -41,6 +41,7 @@ import org.apache.hadoop.hbase.HRegionInfo; import org.apache.hadoop.hbase.HRegionLocation; import org.apache.hadoop.hbase.HTableDescriptor; +import org.apache.hadoop.hbase.InvalidFamilyOperationException; import org.apache.hadoop.hbase.MasterNotRunningException; import org.apache.hadoop.hbase.NotServingRegionException; import org.apache.hadoop.hbase.RegionException; @@ -932,6 +933,20 @@ throws IOException { deleteColumn(Bytes.toBytes(tableName), Bytes.toBytes(columnName)); } + + /** + * If table doesn't exist, throw TableNotFoundException + * + * @param tableName name of table + */ + private void checkTableExistence(final byte [] tableName) throws IOException { + HTableDescriptor htd = getTableDescriptor(tableName); + if (htd == null) { + throw new TableNotFoundException("Table modification could not be " + + "completed as HTableDescriptor is missing for table = " + + Bytes.toString(tableName)); + } + } /** * Delete a column from a table. @@ -944,6 +959,13 @@ public void deleteColumn(final byte [] tableName, final byte [] columnName) throws IOException { try { + HTableDescriptor htd = getTableDescriptor(tableName); + checkTableExistence(tableName); + if(!htd.hasFamily(columnName)) { + throw new InvalidFamilyOperationException( + "Family '" + Bytes.toString(columnName) + "' does not exist so " + + "cannot be deleted"); + } getMaster().deleteColumn(tableName, columnName); } catch (RemoteException e) { throw RemoteExceptionHandler.decodeRemoteException(e); @@ -974,6 +996,13 @@ public void modifyColumn(final byte [] tableName, HColumnDescriptor descriptor) throws IOException { try { + HTableDescriptor htd = getTableDescriptor(tableName); + checkTableExistence(tableName); + if(!htd.hasFamily(descriptor.getName())) { + throw new InvalidFamilyOperationException( + "Family '" + descriptor.getNameAsString() + "' does not exist so " + + "cannot be modified"); + } getMaster().modifyColumn(tableName, descriptor); } catch (RemoteException re) { // Convert RE exceptions in here; client shouldn't have to deal with them, @@ -1421,6 +1450,7 @@ public void modifyTable(final byte [] tableName, HTableDescriptor htd) throws IOException { try { + checkTableExistence(tableName); getMaster().modifyTable(tableName, htd); } catch (RemoteException re) { // Convert RE exceptions in here; client shouldn't have to deal with them,