Search in sources :

Example 6 with ViewsMetadata

use of io.crate.metadata.view.ViewsMetadata in project crate by crate.

the class ViewsITest method testViewCanBeCreatedAndThenReplaced.

@Test
public void testViewCanBeCreatedAndThenReplaced() throws Exception {
    execute("create view v2 as select 1 from sys.cluster");
    assertThat(printedTable(execute("select * from v2").rows()), is("1\n"));
    execute("create or replace view v2 as select 2 from sys.cluster");
    assertThat(printedTable(execute("select * from v2").rows()), is("2\n"));
    for (ClusterService clusterService : internalCluster().getInstances(ClusterService.class)) {
        ViewsMetadata views = clusterService.state().metadata().custom(ViewsMetadata.TYPE);
        assertThat(views, Matchers.notNullValue());
        assertThat(views.contains(RelationName.fromIndexName(sqlExecutor.getCurrentSchema() + ".v2")), is(true));
    }
}
Also used : ClusterService(org.elasticsearch.cluster.service.ClusterService) ViewsMetadata(io.crate.metadata.view.ViewsMetadata) Test(org.junit.Test)

Aggregations

ViewsMetadata (io.crate.metadata.view.ViewsMetadata)6 RelationUnknown (io.crate.exceptions.RelationUnknown)2 HashSet (java.util.HashSet)2 ClusterService (org.elasticsearch.cluster.service.ClusterService)2 Test (org.junit.Test)2 VisibleForTesting (io.crate.common.annotations.VisibleForTesting)1 UserDefinedFunctionsMetadata (io.crate.expression.udf.UserDefinedFunctionsMetadata)1 BlobSchemaInfo (io.crate.metadata.blob.BlobSchemaInfo)1 InformationSchemaInfo (io.crate.metadata.information.InformationSchemaInfo)1 PgCatalogSchemaInfo (io.crate.metadata.pgcatalog.PgCatalogSchemaInfo)1 SysSchemaInfo (io.crate.metadata.sys.SysSchemaInfo)1 SchemaInfo (io.crate.metadata.table.SchemaInfo)1 ViewMetadata (io.crate.metadata.view.ViewMetadata)1