@Test
  public void testDropDatabaseWithCustomPartitionPath() throws Exception {
    String dbName = "dropdb";
    String tblName1 = "droptbl1";
    String tblName2 = "droptbl2";
    String tblName3 = "droptbl3";

    // A new client to support drop these 3 tables in one batch
    Configuration newConf = MetastoreConf.newMetastoreConf(new Configuration(conf));
    MetastoreConf.setLongVar(newConf, ConfVars.BATCH_RETRIEVE_MAX, 3);
    IMetaStoreClient client = RetryingMetaStoreClient.getProxy(newConf, getHookLoader(), HiveMetaStoreClient.class.getName());

    // Setup
    silentDropDatabase(dbName);
    new DatabaseBuilder()
        .setName(dbName)
        .create(client, conf);

    new TableBuilder()
        .setDbName(dbName)
        .setTableName(tblName1)
        .addCol("c1", ColumnType.STRING_TYPE_NAME)
        .addPartCol("p1", ColumnType.STRING_TYPE_NAME)
        .create(client, conf);

    new TableBuilder()
        .setDbName(dbName)
        .setTableName(tblName2)
        .addCol("c1", ColumnType.STRING_TYPE_NAME)
        .addPartCol("p1", ColumnType.STRING_TYPE_NAME)
        .create(client, conf);

    new TableBuilder()
        .setDbName(dbName)
        .setTableName(tblName3)
        .addCol("c1", ColumnType.STRING_TYPE_NAME)
        .create(client, conf);

    Path rootPath = warehouse.getWhRoot();
    Path path1 = new Path(rootPath, tblName1);
    Table tbl1 = client.getTable(dbName, tblName1);
    Table tbl2 = client.getTable(dbName, tblName2);
    Table tbl3 = client.getTable(dbName, tblName3);
    List<String> vals = Lists.newArrayList("p1");

    // partition1 whose path does not belong to table1
    Partition part1 = makePartitionObjectWithAbsoluteLocation(dbName, tblName1, vals, tbl1, path1.toString());
    client.add_partition(part1);

    // partition2 whose path belongs to table2
    Partition part2 = makePartitionObject(dbName, tblName2, vals, tbl2, "/part2");
    client.add_partition(part2);

    client.dropDatabase(dbName, true, true, true);
    FileSystem fs = FileSystem.get(path1.toUri(), conf);
    assertFalse(fs.exists(new Path(tbl1.getSd().getLocation())));
    assertFalse(fs.exists(new Path(tbl2.getSd().getLocation())));
    assertFalse(fs.exists(new Path(tbl3.getSd().getLocation())));
    assertFalse(fs.exists(path1));

    client.close();
  }
Test table objects can be retrieved in batches
standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/TestHiveMetaStore.java