use of io.trino.spi.connector.ConnectorViewDefinition.ViewColumn in project trino by trinodb.
the class AbstractTestHive method doCreateView.
private void doCreateView(SchemaTableName viewName, boolean replace) {
String viewData = "test data";
ConnectorViewDefinition definition = new ConnectorViewDefinition(viewData, Optional.empty(), Optional.empty(), ImmutableList.of(new ViewColumn("test", BIGINT.getTypeId())), Optional.empty(), Optional.empty(), true);
try (Transaction transaction = newTransaction()) {
transaction.getMetadata().createView(newSession(), viewName, definition, replace);
transaction.commit();
}
try (Transaction transaction = newTransaction()) {
ConnectorMetadata metadata = transaction.getMetadata();
assertThat(metadata.getView(newSession(), viewName)).map(ConnectorViewDefinition::getOriginalSql).contains(viewData);
Map<SchemaTableName, ConnectorViewDefinition> views = metadata.getViews(newSession(), Optional.of(viewName.getSchemaName()));
assertEquals(views.size(), 1);
assertEquals(views.get(viewName).getOriginalSql(), definition.getOriginalSql());
assertTrue(metadata.listViews(newSession(), Optional.of(viewName.getSchemaName())).contains(viewName));
}
}
use of io.trino.spi.connector.ConnectorViewDefinition.ViewColumn in project trino by trinodb.
the class TestConnectorViewDefinition method assertBaseView.
private static void assertBaseView(ConnectorViewDefinition view) {
assertEquals(view.getOriginalSql(), "SELECT 42 x");
assertEquals(view.getColumns().size(), 1);
ViewColumn column = getOnlyElement(view.getColumns());
assertEquals(column.getName(), "x");
assertEquals(column.getType(), BIGINT.getTypeId());
assertRoundTrip(view);
}
Aggregations