use of io.trino.spi.security.TrinoPrincipal in project trino by trinodb.
the class TestMemoryMetadata method testCreateViewWithoutReplace.
@Test
public void testCreateViewWithoutReplace() {
SchemaTableName test = new SchemaTableName("test", "test_view");
metadata.createSchema(SESSION, "test", ImmutableMap.of(), new TrinoPrincipal(USER, SESSION.getUser()));
try {
metadata.createView(SESSION, test, testingViewDefinition("test"), false);
} catch (Exception e) {
fail("should have succeeded");
}
assertThatThrownBy(() -> metadata.createView(SESSION, test, testingViewDefinition("test"), false)).isInstanceOf(TrinoException.class).hasMessageMatching("View already exists: test\\.test_view");
}
use of io.trino.spi.security.TrinoPrincipal in project trino by trinodb.
the class TestMemoryMetadata method testCreateSchema.
@Test
public void testCreateSchema() {
assertEquals(metadata.listSchemaNames(SESSION), ImmutableList.of("default"));
metadata.createSchema(SESSION, "test", ImmutableMap.of(), new TrinoPrincipal(USER, SESSION.getUser()));
assertEquals(metadata.listSchemaNames(SESSION), ImmutableList.of("default", "test"));
assertEquals(metadata.listTables(SESSION, Optional.of("test")), ImmutableList.of());
SchemaTableName tableName = new SchemaTableName("test", "first_table");
metadata.createTable(SESSION, new ConnectorTableMetadata(tableName, ImmutableList.of(), ImmutableMap.of()), false);
assertEquals(metadata.listTables(SESSION, Optional.empty()), ImmutableList.of(tableName));
assertEquals(metadata.listTables(SESSION, Optional.of("test")), ImmutableList.of(tableName));
assertEquals(metadata.listTables(SESSION, Optional.of("default")), ImmutableList.of());
}
Aggregations