@Override public List<String> getAllTables(String catName, String dbName) throws MetaException { return objectStore.getAllTables(catName, dbName); }
@Test public void testQueryCloseOnError() throws Exception { ObjectStore spy = Mockito.spy(objectStore); spy.getAllDatabases(DEFAULT_CATALOG_NAME); spy.getAllFunctions(DEFAULT_CATALOG_NAME); spy.getAllTables(DEFAULT_CATALOG_NAME, DB1); spy.getPartitionCount(); Mockito.verify(spy, Mockito.times(3)) .rollbackAndCleanup(Mockito.anyBoolean(), Mockito.<Query>anyObject()); }
objectStore.createTable(tbl1); List<String> tables = objectStore.getAllTables(DEFAULT_CATALOG_NAME, DB1); Assert.assertEquals(1, tables.size()); Assert.assertEquals(TABLE1, tables.get(0)); tables = objectStore.getAllTables(DEFAULT_CATALOG_NAME, DB1); Assert.assertEquals(2, tables.size()); tables = objectStore.getAllTables(DEFAULT_CATALOG_NAME, DB1); Assert.assertEquals(1, tables.size()); tables = objectStore.getAllTables(DEFAULT_CATALOG_NAME, DB1); Assert.assertEquals(0, tables.size());
@Override public List<String> getAllTables(String dbName) throws MetaException { return filterTables(dbName, super.getAllTables(dbName)); }
public boolean dropDatabase(String dbname) throws NoSuchObjectException, MetaException { boolean success = false; LOG.info("Dropping database " + dbname + " along with all tables"); dbname = dbname.toLowerCase(); try { openTransaction(); // first drop tables for (String tableName : getAllTables(dbname)) { dropTable(dbname, tableName); } // then drop the database MDatabase db = getMDatabase(dbname); pm.retrieve(db); if (db != null) { List<MDBPrivilege> dbGrants = this.listDatabaseGrants(dbname); if (dbGrants != null && dbGrants.size() > 0) { pm.deletePersistentAll(dbGrants); } pm.deletePersistent(db); } success = commitTransaction(); } finally { if (!success) { rollbackTransaction(); } } return success; }