Create views if they don't already exist.

This commit is contained in:
Greg Burd 2017-10-11 14:24:01 -04:00
parent 7156d733fa
commit 605529979d
2 changed files with 3 additions and 1 deletions

View file

@ -213,7 +213,8 @@ public final class SchemaUtil {
if (o.size() > 0) { if (o.size() > 0) {
clustering = "WITH CLUSTERING ORDER BY (" + String.join(", ", o) + ")"; clustering = "WITH CLUSTERING ORDER BY (" + String.join(", ", o) + ")";
} }
return new CreateMaterializedView(keyspace, viewName, where, primaryKey, clustering); return new CreateMaterializedView(keyspace, viewName, where, primaryKey, clustering)
.ifNotExists();
} }
public static SchemaStatement dropMaterializedView( public static SchemaStatement dropMaterializedView(

View file

@ -29,6 +29,7 @@ import org.junit.Test;
// See: https://docs.datastax.com/en/cql/3.3/cql/cql_using/useCreateMV.html // See: https://docs.datastax.com/en/cql/3.3/cql/cql_using/useCreateMV.html
// https://docs.datastax.com/en/cql/3.3/cql/cql_reference/cqlCreateMaterializedView.html // https://docs.datastax.com/en/cql/3.3/cql/cql_reference/cqlCreateMaterializedView.html
// https://www.datastax.com/dev/blog/materialized-view-performance-in-cassandra-3-x // https://www.datastax.com/dev/blog/materialized-view-performance-in-cassandra-3-x
// https://cassandra-zone.com/materialized-views/
public class MaterializedViewTest extends AbstractEmbeddedCassandraTest { public class MaterializedViewTest extends AbstractEmbeddedCassandraTest {
static Cyclist cyclist; static Cyclist cyclist;