From 605529979db703bb6d5b47b407be416dee7c3bd1 Mon Sep 17 00:00:00 2001 From: Greg Burd Date: Wed, 11 Oct 2017 14:24:01 -0400 Subject: [PATCH] Create views if they don't already exist. --- src/main/java/net/helenus/core/SchemaUtil.java | 3 ++- .../test/integration/core/views/MaterializedViewTest.java | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/helenus/core/SchemaUtil.java b/src/main/java/net/helenus/core/SchemaUtil.java index 6a228e9..5e33b3d 100644 --- a/src/main/java/net/helenus/core/SchemaUtil.java +++ b/src/main/java/net/helenus/core/SchemaUtil.java @@ -213,7 +213,8 @@ public final class SchemaUtil { if (o.size() > 0) { 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( diff --git a/src/test/java/net/helenus/test/integration/core/views/MaterializedViewTest.java b/src/test/java/net/helenus/test/integration/core/views/MaterializedViewTest.java index a8df217..74f02fa 100644 --- a/src/test/java/net/helenus/test/integration/core/views/MaterializedViewTest.java +++ b/src/test/java/net/helenus/test/integration/core/views/MaterializedViewTest.java @@ -29,6 +29,7 @@ import org.junit.Test; // 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://www.datastax.com/dev/blog/materialized-view-performance-in-cassandra-3-x +// https://cassandra-zone.com/materialized-views/ public class MaterializedViewTest extends AbstractEmbeddedCassandraTest { static Cyclist cyclist;