kikocis/java-driver public
Changesets · Branches · Tags · Compare
| Changeset | a607de2d38d9ad0d49f01b7207d5f431759a06e636a289cab0dcd05eb54f289d |
|---|---|
| Author | Alexandre Dutra <alexandre.dutra@datastax.com> · 2015-09-17 15:45 +02:00 |
| Committer | Alexandre Dutra <alexandre.dutra@datastax.com> · 2015-09-17 18:49 +02:00 |
| Parents | 8e3e8fb031fa |
3 files changed
modified driver-core/src/main/java/com/datastax/driver/core/Cluster.java +4 −0
| @@ -2195,7 +2195,11 @@ | ||
| 2195 | 2195 | } else { |
| 2196 | 2196 | switch (scc.targetType) { |
| 2197 | 2197 | case TABLE: |
| 2198 | + // we can't tell whether it's a table or a view, | |
| 2199 | + // but since two objects cannot have the same name, | |
| 2200 | + // try removing both | |
| 2198 | 2201 | keyspace.removeTable(scc.targetName); |
| 2202 | + keyspace.removeMaterializedView(scc.targetName); | |
| 2199 | 2203 | break; |
| 2200 | 2204 | case TYPE: |
| 2201 | 2205 | keyspace.removeUserType(scc.targetName); |
modified driver-core/src/main/java/com/datastax/driver/core/DefaultResultSetFuture.java +4 −0
| @@ -88,7 +88,11 @@ | ||
| 88 | 88 | } else { |
| 89 | 89 | switch (scc.targetType) { |
| 90 | 90 | case TABLE: |
| 91 | + // we can't tell whether it's a table or a view, | |
| 92 | + // but since two objects cannot have the same name, | |
| 93 | + // try removing both | |
| 91 | 94 | keyspace.removeTable(scc.targetName); |
| 95 | + keyspace.removeMaterializedView(scc.targetName); | |
| 92 | 96 | break; |
| 93 | 97 | case TYPE: |
| 94 | 98 | keyspace.removeUserType(scc.targetName); |
modified driver-core/src/test/java/com/datastax/driver/core/SchemaChangesTest.java +38 −0
| @@ -219,6 +219,42 @@ | ||
| 219 | 219 | .isNull(); |
| 220 | 220 | } |
| 221 | 221 | |
| 222 | + @Test(groups = "short", dataProvider = "existingKeyspaceName") | |
| 223 | + @CassandraVersion(major = 3.0) | |
| 224 | + public void should_notify_of_view_creation(String keyspace) { | |
| 225 | + session.execute(String.format("CREATE TABLE %s.table1 (pk int PRIMARY KEY, c int)", keyspace)); | |
| 226 | + session.execute(String.format("CREATE MATERIALIZED VIEW %s.mv1 AS SELECT c FROM %s.table1 WHERE c IS NOT NULL PRIMARY KEY (pk, c)", keyspace, keyspace)); | |
| 227 | + | |
| 228 | + for (Metadata m : metadatas) | |
| 229 | + assertThat(m.getKeyspace(keyspace).getMaterializedView("mv1")).isNotNull(); | |
| 230 | + } | |
| 231 | + | |
| 232 | + @Test(groups = "short", dataProvider = "existingKeyspaceName") | |
| 233 | + @CassandraVersion(major = 3.0) | |
| 234 | + public void should_notify_of_view_update(String keyspace) { | |
| 235 | + session.execute(String.format("CREATE TABLE %s.table1 (pk int PRIMARY KEY, c int)", keyspace)); | |
| 236 | + session.execute(String.format("CREATE MATERIALIZED VIEW %s.mv1 AS SELECT c FROM %s.table1 WHERE c IS NOT NULL PRIMARY KEY (pk, c) WITH compaction = { 'class' : 'SizeTieredCompactionStrategy' }", keyspace, keyspace)); | |
| 237 | + | |
| 238 | + for (Metadata m : metadatas) | |
| 239 | + assertThat(m.getKeyspace(keyspace).getMaterializedView("mv1").getOptions().getCompaction().get("class")).contains("SizeTieredCompactionStrategy"); | |
| 240 | + | |
| 241 | + session.execute(String.format("ALTER MATERIALIZED VIEW %s.mv1 WITH compaction = { 'class' : 'LeveledCompactionStrategy' }", keyspace)); | |
| 242 | + | |
| 243 | + for (Metadata m : metadatas) | |
| 244 | + assertThat(m.getKeyspace(keyspace).getMaterializedView("mv1").getOptions().getCompaction().get("class")).contains("LeveledCompactionStrategy"); | |
| 245 | + } | |
| 246 | + | |
| 247 | + @Test(groups = "short", dataProvider = "existingKeyspaceName") | |
| 248 | + @CassandraVersion(major = 3.0) | |
| 249 | + public void should_notify_of_view_drop(String keyspace) { | |
| 250 | + session.execute(String.format("CREATE TABLE %s.table1 (pk int PRIMARY KEY, c int)", keyspace)); | |
| 251 | + session.execute(String.format("CREATE MATERIALIZED VIEW %s.mv1 AS SELECT c FROM %s.table1 WHERE c IS NOT NULL PRIMARY KEY (pk, c)", keyspace, keyspace)); | |
| 252 | + session.execute(String.format("DROP MATERIALIZED VIEW %s.mv1", keyspace)); | |
| 253 | + | |
| 254 | + for (Metadata m : metadatas) | |
| 255 | + assertThat(m.getKeyspace(keyspace).getMaterializedView("mv1")).isNull(); | |
| 256 | + } | |
| 257 | + | |
| 222 | 258 | @DataProvider(name = "newKeyspaceName") |
| 223 | 259 | public static Object[][] newKeyspaceName() { |
| 224 | 260 | return new Object[][]{ { "lowercase2" }, { "\"CaseSensitive2\"" } }; |
| @@ -276,6 +312,8 @@ | ||
| 276 | 312 | session.executeAsync("DROP FUNCTION \"CaseSensitive\".plus"), |
| 277 | 313 | session.executeAsync("DROP AGGREGATE lowercase.sum"), |
| 278 | 314 | session.executeAsync("DROP AGGREGATE \"CaseSensitive\".sum"), |
| 315 | + session.executeAsync("DROP MATERIALIZED VIEW lowercase.mv1"), | |
| 316 | + session.executeAsync("DROP MATERIALIZED VIEW \"CaseSensitive\".mv1"), | |
| 279 | 317 | session.executeAsync("DROP KEYSPACE lowercase2"), |
| 280 | 318 | session.executeAsync("DROP KEYSPACE \"CaseSensitive2\"") |
| 281 | 319 | )); |