// create the table
db.createTable(tbl);
return 0;
}
dropTableDesc dropTbl = work.getDropTblDesc();
if (dropTbl != null) {
if(dropTbl.getPartSpecs() == null) {
// drop the table
db.dropTable(dropTbl.getTableName());
} else {
// drop partitions in the list
Table tbl = db.getTable(dropTbl.getTableName());
List<Partition> parts = new ArrayList<Partition>();
for(HashMap<String, String> partSpec : dropTbl.getPartSpecs()) {
Partition part = db.getPartition(tbl, partSpec, false);
if(part == null) {
console.printInfo("Partition " + partSpec + " does not exist.");
} else {
parts.add(part);
}
}
// drop all existing partitions from the list
for (Partition partition : parts) {
console.printInfo("Dropping the partition " + partition.getName());
db.dropPartition(MetaStoreUtils.DEFAULT_DATABASE_NAME,
dropTbl.getTableName(),
partition.getValues(),
true); //drop data for the partition
}
}
return 0;