Java Code Examples for org.apache.hadoop.hive.metastore.HiveMetaStoreClient#dropTable()
The following examples show how to use
org.apache.hadoop.hive.metastore.HiveMetaStoreClient#dropTable() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WaggleDanceIntegrationTest.java From waggle-dance with Apache License 2.0 | 5 votes |
@Test public void readWriteCreateAllowed() throws Exception { String writableDatabase = "writable_db"; localServer.createDatabase(writableDatabase); runner = WaggleDanceRunner .builder(configLocation) .primary("primary", localServer.getThriftConnectionUri(), AccessControlType.READ_AND_WRITE_AND_CREATE) .build(); runWaggleDance(runner); HiveMetaStoreClient proxy = getWaggleDanceClient(); // create rights proxy.createDatabase(new Database("newDB", "", new File(localWarehouseUri, "newDB").toURI().toString(), null)); Database newDB = proxy.getDatabase("newDB"); assertNotNull(newDB); // read rights Table localTable = localServer.client().getTable(LOCAL_DATABASE, LOCAL_TABLE); Table waggledLocalTable = proxy.getTable(LOCAL_DATABASE, LOCAL_TABLE); assertThat(waggledLocalTable, is(localTable)); // write rights proxy.dropTable(LOCAL_DATABASE, LOCAL_TABLE); try { proxy.getTable(LOCAL_DATABASE, LOCAL_TABLE); fail("Should get NoSuchObjectException"); } catch (NoSuchObjectException e) { // Local table should be allowed to drop, so it now no longer exists and we get an appropriate exception } }
Example 2
Source File: WaggleDanceIntegrationTest.java From waggle-dance with Apache License 2.0 | 5 votes |
@Test public void readWriteCreateAllowedPrefixed() throws Exception { String writableDatabase = "writable_db"; localServer.createDatabase(writableDatabase); runner = WaggleDanceRunner .builder(configLocation) .databaseResolution(DatabaseResolution.PREFIXED) .primary("primary", localServer.getThriftConnectionUri(), AccessControlType.READ_AND_WRITE_AND_CREATE) .build(); runWaggleDance(runner); HiveMetaStoreClient proxy = getWaggleDanceClient(); // create rights proxy.createDatabase(new Database("newDB", "", new File(localWarehouseUri, "newDB").toURI().toString(), null)); Database newDB = proxy.getDatabase("newDB"); assertNotNull(newDB); // read rights Table localTable = localServer.client().getTable(LOCAL_DATABASE, LOCAL_TABLE); Table waggledLocalTable = proxy.getTable(LOCAL_DATABASE, LOCAL_TABLE); assertThat(waggledLocalTable, is(localTable)); // write rights proxy.dropTable(LOCAL_DATABASE, LOCAL_TABLE); try { proxy.getTable(LOCAL_DATABASE, LOCAL_TABLE); fail("Should get NoSuchObjectException"); } catch (NoSuchObjectException e) { // Local table should be allowed to drop, so it now no longer exists and we get an appropriate exception } }
Example 3
Source File: WaggleDanceIntegrationTest.java From waggle-dance with Apache License 2.0 | 5 votes |
@Test public void federatedWritesSucceedIfReadAndWriteOnDatabaseWhiteListIsConfigured() throws Exception { runner = WaggleDanceRunner .builder(configLocation) .databaseResolution(DatabaseResolution.PREFIXED) .primary("primary", localServer.getThriftConnectionUri(), AccessControlType.READ_ONLY) .federate(SECONDARY_METASTORE_NAME, remoteServer.getThriftConnectionUri(), READ_AND_WRITE_ON_DATABASE_WHITELIST, new String[] { REMOTE_DATABASE }, new String[] { REMOTE_DATABASE }) .build(); runWaggleDance(runner); HiveMetaStoreClient proxy = getWaggleDanceClient(); String waggledRemoteDbName = PREFIXED_REMOTE_DATABASE; assertTypicalRemoteTable(proxy, waggledRemoteDbName); // get succeeds proxy.getTable(waggledRemoteDbName, REMOTE_TABLE); // drop table proxy.dropTable(waggledRemoteDbName, REMOTE_TABLE); try { // get fails proxy.getTable(waggledRemoteDbName, REMOTE_TABLE); fail("Should get NoSuchObjectException"); } catch (NoSuchObjectException e) { // Federated table should be allowed to drop, so it now no longer exists and we get an appropriate exception } }
Example 4
Source File: WaggleDanceIntegrationTest.java From waggle-dance with Apache License 2.0 | 5 votes |
@Test public void federatedWritesFailIfReadAndWriteOnDatabaseWhiteListIsNotConfigured() throws Exception { runner = WaggleDanceRunner .builder(configLocation) .databaseResolution(DatabaseResolution.PREFIXED) .primary("primary", localServer.getThriftConnectionUri(), AccessControlType.READ_ONLY) .federate(SECONDARY_METASTORE_NAME, remoteServer.getThriftConnectionUri()) .build(); runWaggleDance(runner); HiveMetaStoreClient proxy = getWaggleDanceClient(); String waggledRemoteDbName = PREFIXED_REMOTE_DATABASE; assertTypicalRemoteTable(proxy, waggledRemoteDbName); // get succeeds proxy.getTable(waggledRemoteDbName, REMOTE_TABLE); try { // drop fails proxy.dropTable(waggledRemoteDbName, REMOTE_TABLE); fail("Should get MetaException"); } catch (MetaException e) { // Federated table should not be allowed to drop } }
Example 5
Source File: WaggleDanceIntegrationTest.java From waggle-dance with Apache License 2.0 | 5 votes |
@Test public void federatedWritesFailIfReadAndWriteOnDatabaseWhiteListDoesNotIncludeDb() throws Exception { runner = WaggleDanceRunner .builder(configLocation) .databaseResolution(DatabaseResolution.PREFIXED) .primary("primary", localServer.getThriftConnectionUri(), AccessControlType.READ_ONLY) .federate(SECONDARY_METASTORE_NAME, remoteServer.getThriftConnectionUri(), READ_AND_WRITE_ON_DATABASE_WHITELIST, new String[] { REMOTE_DATABASE }, new String[] { "mismatch" }) .build(); runWaggleDance(runner); HiveMetaStoreClient proxy = getWaggleDanceClient(); String waggledRemoteDbName = PREFIXED_REMOTE_DATABASE; assertTypicalRemoteTable(proxy, waggledRemoteDbName); // get succeeds proxy.getTable(waggledRemoteDbName, REMOTE_TABLE); try { // drop fails proxy.dropTable(waggledRemoteDbName, REMOTE_TABLE); fail("Should get MetaException"); } catch (MetaException e) { // Federated table should not be allowed to drop } }