@Override public void dropView(ConnectorSession session, SchemaTableName viewName) { try (ThreadContextClassLoader ignored = new ThreadContextClassLoader(classLoader)) { delegate.dropView(session, viewName); } }
@Override public void dropView(Session session, QualifiedObjectName viewName) { CatalogMetadata catalogMetadata = getCatalogMetadataForWrite(session, viewName.getCatalogName()); ConnectorId connectorId = catalogMetadata.getConnectorId(); ConnectorMetadata metadata = catalogMetadata.getMetadata(); metadata.dropView(session.toConnectorSession(connectorId), viewName.asSchemaTableName()); }
@Test public void testViewCreation() { SchemaTableName temporaryCreateView = temporaryTable("create_view"); try { verifyViewCreation(temporaryCreateView); } finally { try (Transaction transaction = newTransaction()) { ConnectorMetadata metadata = transaction.getMetadata(); metadata.dropView(newSession(), temporaryCreateView); transaction.commit(); } catch (RuntimeException e) { // this usually occurs because the view was not created } } }
@Override public void dropView(ConnectorSession session, SchemaTableName viewName) { try (ThreadContextClassLoader ignored = new ThreadContextClassLoader(classLoader)) { delegate.dropView(session, viewName); } }
@Override public void dropView(Session session, QualifiedObjectName viewName) { ConnectorEntry entry = connectorsByCatalog.get(viewName.getCatalogName()); checkArgument(entry != null, "Catalog %s does not exist", viewName.getCatalogName()); ConnectorMetadata metadata = entry.getMetadataForWrite(session); metadata.dropView(session.toConnectorSession(entry.getCatalog()), viewName.asSchemaTableName()); }
@Test public void testViewCreation() { try { verifyViewCreation(); } finally { try { newMetadata().dropView(newSession(), temporaryCreateView); } catch (RuntimeException e) { // this usually occurs because the view was not created } } }
private void verifyViewCreation() { // replace works for new view doCreateView(temporaryCreateView, true); // replace works for existing view doCreateView(temporaryCreateView, true); // create fails for existing view try { doCreateView(temporaryCreateView, false); fail("create existing should fail"); } catch (ViewAlreadyExistsException e) { assertEquals(e.getViewName(), temporaryCreateView); } ConnectorMetadata metadata = newMetadata(); // drop works when view exists metadata.dropView(newSession(), temporaryCreateView); assertEquals(metadata.getViews(newSession(), temporaryCreateView.toSchemaTablePrefix()).size(), 0); assertFalse(metadata.listViews(newSession(), temporaryCreateView.getSchemaName()).contains(temporaryCreateView)); // drop fails when view does not exist try { metadata.dropView(newSession(), temporaryCreateView); fail("drop non-existing should fail"); } catch (ViewNotFoundException e) { assertEquals(e.getViewName(), temporaryCreateView); } // create works for new view doCreateView(temporaryCreateView, false); }
@Test public void testViewCreation() { SchemaTableName temporaryCreateView = temporaryTable("create_view"); try { verifyViewCreation(temporaryCreateView); } finally { try (Transaction transaction = newTransaction()) { ConnectorMetadata metadata = transaction.getMetadata(); metadata.dropView(newSession(), temporaryCreateView); transaction.commit(); } catch (RuntimeException e) { // this usually occurs because the view was not created } } }