Search in sources :

Example 1 with ViewNotFoundException

use of io.trino.spi.connector.ViewNotFoundException in project trino by trinodb.

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);
}
Also used : ConnectorMetadata(io.trino.spi.connector.ConnectorMetadata) ViewNotFoundException(io.trino.spi.connector.ViewNotFoundException)

Aggregations

ConnectorMetadata (io.trino.spi.connector.ConnectorMetadata)1 ViewNotFoundException (io.trino.spi.connector.ViewNotFoundException)1