use of io.prestosql.spi.connector.ViewNotFoundException in project hetu-core by openlookeng.
the class AbstractTestHive method verifyViewCreation.
private void verifyViewCreation(SchemaTableName temporaryCreateView) {
// 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);
}
try (Transaction transaction = newTransaction()) {
ConnectorMetadata metadata = transaction.getMetadata();
// drop works when view exists
metadata.dropView(newSession(), temporaryCreateView);
transaction.commit();
}
try (Transaction transaction = newTransaction()) {
ConnectorMetadata metadata = transaction.getMetadata();
assertThat(metadata.getView(newSession(), temporaryCreateView)).isEmpty();
assertThat(metadata.getViews(newSession(), Optional.of(temporaryCreateView.getSchemaName()))).doesNotContainKey(temporaryCreateView);
assertThat(metadata.listViews(newSession(), Optional.of(temporaryCreateView.getSchemaName()))).doesNotContain(temporaryCreateView);
}
// drop fails when view does not exist
try (Transaction transaction = newTransaction()) {
ConnectorMetadata metadata = transaction.getMetadata();
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);
}
Aggregations