@Test
  public void testDropDatabaseCascadeMVMultiDB() throws Exception {
    String dbName1 = "db1";
    String tableName1 = "table1";
    String dbName2 = "db2";
    String tableName2 = "table2";
    String mvName = "mv1";

    // Setup
    silentDropDatabase(dbName1);
    silentDropDatabase(dbName2);

    Database db1 = new Database();
    db1.setName(dbName1);
    client.createDatabase(db1);
    Table table1 = createTable(dbName1, tableName1);
    Database db2 = new Database();
    db2.setName(dbName2);
    client.createDatabase(db2);
    Table table2 = createTable(dbName2, tableName2);

    createMaterializedView(dbName2, mvName, Sets.newHashSet(table1, table2));

    boolean exceptionFound = false;
    try {
      // Cannot drop db1 because mv1 uses one of its tables
      // TODO: Error message coming from metastore is currently not very concise
      // (foreign key violation), we should make it easily understandable
      client.dropDatabase(dbName1, true, true, true);
    } catch (Exception e) {
      exceptionFound = true;
    }
    assertTrue(exceptionFound);

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