Search in sources :

Example 6 with ConnectorViewDefinition

use of com.facebook.presto.spi.ConnectorViewDefinition in project presto by prestodb.

the class AbstractTestHiveClient method doCreateView.

private void doCreateView(SchemaTableName viewName, boolean replace) {
    String viewData = "test data";
    try (Transaction transaction = newTransaction()) {
        transaction.getMetadata().createView(newSession(), viewName, viewData, replace);
        transaction.commit();
    }
    try (Transaction transaction = newTransaction()) {
        ConnectorMetadata metadata = transaction.getMetadata();
        Map<SchemaTableName, ConnectorViewDefinition> views = metadata.getViews(newSession(), viewName.toSchemaTablePrefix());
        assertEquals(views.size(), 1);
        assertEquals(views.get(viewName).getViewData(), viewData);
        assertTrue(metadata.listViews(newSession(), viewName.getSchemaName()).contains(viewName));
    }
}
Also used : ConnectorMetadata(com.facebook.presto.spi.connector.ConnectorMetadata) SchemaTableName(com.facebook.presto.spi.SchemaTableName) ConnectorViewDefinition(com.facebook.presto.spi.ConnectorViewDefinition)

Aggregations

ConnectorViewDefinition (com.facebook.presto.spi.ConnectorViewDefinition)6 SchemaTableName (com.facebook.presto.spi.SchemaTableName)6 ConnectorMetadata (com.facebook.presto.spi.connector.ConnectorMetadata)4 ConnectorId (com.facebook.presto.connector.ConnectorId)3 QualifiedObjectName.convertFromSchemaTableName (com.facebook.presto.metadata.QualifiedObjectName.convertFromSchemaTableName)3 SchemaTablePrefix (com.facebook.presto.spi.SchemaTablePrefix)3 ConnectorSession (com.facebook.presto.spi.ConnectorSession)2 LinkedHashMap (java.util.LinkedHashMap)2 Table (com.facebook.presto.hive.metastore.Table)1 ViewColumn (com.facebook.presto.metadata.ViewDefinition.ViewColumn)1 ColumnMetadata (com.facebook.presto.spi.ColumnMetadata)1 ImmutableCollectors.toImmutableList (com.facebook.presto.util.ImmutableCollectors.toImmutableList)1 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 Test (org.testng.annotations.Test)1