tbl = get_table(dbname, name);
if (tbl == null) {
throw new NoSuchObjectException(name + " doesn't exist");
}
if (tbl.getSd() == null) {
throw new MetaException("Table metadata is corrupted");
}
isIndexTable = isIndexTable(tbl);
if (isIndexTable) {
throw new RuntimeException(
"The table " + name + " is an index table. Please do drop index instead.");
}
if (!isIndexTable) {
try {
List<Index> indexes = ms.getIndexes(dbname, name, Short.MAX_VALUE);
while(indexes != null && indexes.size()>0) {
for (Index idx : indexes) {
this.drop_index_by_name(dbname, name, idx.getIndexName(), true);
}
indexes = ms.getIndexes(dbname, name, Short.MAX_VALUE);
}
} catch (TException e) {
throw new MetaException(e.getMessage());
}
}
isExternal = isExternal(tbl);
if (tbl.getSd().getLocation() != null) {
tblPath = new Path(tbl.getSd().getLocation());
}
if (!ms.dropTable(dbname, name)) {
throw new MetaException("Unable to drop table");
}
tbl = null; // table collections disappear after dropping
success = ms.commitTransaction();
} finally {
if (!success) {