You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by br...@apache.org on 2020/07/14 16:09:34 UTC
[cassandra] branch trunk updated: Improve messaging on indexing
frozen collections
This is an automated email from the ASF dual-hosted git repository.
brandonwilliams pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/cassandra.git
The following commit(s) were added to refs/heads/trunk by this push:
new 9e74b67 Improve messaging on indexing frozen collections
9e74b67 is described below
commit 9e74b670d8e680b87af4ce28103587cda1287bf8
Author: Rocco Varela <ro...@gmail.com>
AuthorDate: Mon Jun 29 18:05:26 2020 -0700
Improve messaging on indexing frozen collections
Patch by Rocco Varela, reviewed by Bryn Cooke, Zhao Yang, and
brandonwilliams for CASSANDRA-15908
---
CHANGES.txt | 1 +
.../cql3/statements/schema/CreateIndexStatement.java | 3 ++-
.../validation/entities/FrozenCollectionsTest.java | 2 +-
.../cql3/validation/entities/SecondaryIndexTest.java | 4 ++--
.../org/apache/cassandra/index/CustomIndexTest.java | 18 +++++++++---------
5 files changed, 15 insertions(+), 13 deletions(-)
diff --git a/CHANGES.txt b/CHANGES.txt
index 60d1e22..15dd123 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
4.0-alpha5
+ * Improve messaging on indexing frozen collections (CASSANDRA-15908)
* USING_G1 is incorrectly set in cassandra-env.sh if G1 is explicitly disabled with -UseG1GC (CASSANDRA-15931)
* Update compaction_throughput_mb_per_sec throttle default to 64 (CASSANDRA-14902)
* Add option to disable compaction at startup (CASSANDRA-15927)
diff --git a/src/java/org/apache/cassandra/cql3/statements/schema/CreateIndexStatement.java b/src/java/org/apache/cassandra/cql3/statements/schema/CreateIndexStatement.java
index 18c6511..e011c81 100644
--- a/src/java/org/apache/cassandra/cql3/statements/schema/CreateIndexStatement.java
+++ b/src/java/org/apache/cassandra/cql3/statements/schema/CreateIndexStatement.java
@@ -175,7 +175,8 @@ public final class CreateIndexStatement extends AlterSchemaStatement
throw ire("Cannot create secondary index on the only partition key column %s", column);
if (column.type.isFrozenCollection() && target.type != Type.FULL)
- throw ire("Cannot create %s() index on frozen column %s. Frozen collections only support full() indexes", target.type, column);
+ throw ire("Cannot create %s() index on frozen column %s. Frozen collections are immutable and must be fully " +
+ "indexed by using the 'full(%s)' modifier", target.type, column, column);
if (!column.type.isFrozenCollection() && target.type == Type.FULL)
throw ire("full() indexes can only be created on frozen collections");
diff --git a/test/unit/org/apache/cassandra/cql3/validation/entities/FrozenCollectionsTest.java b/test/unit/org/apache/cassandra/cql3/validation/entities/FrozenCollectionsTest.java
index 39ae392..ccf8b59 100644
--- a/test/unit/org/apache/cassandra/cql3/validation/entities/FrozenCollectionsTest.java
+++ b/test/unit/org/apache/cassandra/cql3/validation/entities/FrozenCollectionsTest.java
@@ -557,7 +557,7 @@ public class FrozenCollectionsTest extends CQLTester
assertInvalidIndexCreationWithMessage("CREATE INDEX ON %s (full(a))", "Cannot create secondary index on the only partition key column");
assertInvalidIndexCreationWithMessage("CREATE INDEX ON %s (keys(a))", "Cannot create secondary index on the only partition key column");
assertInvalidIndexCreationWithMessage("CREATE INDEX ON %s (keys(b))", "Cannot create keys() index on frozen column b. " +
- "Frozen collections only support full() indexes");
+ "Frozen collections only support indexes on the entire data structure");
createTable("CREATE TABLE %s (a int, b frozen<list<int>>, c frozen<set<int>>, d frozen<map<int, text>>, PRIMARY KEY (a, b))");
diff --git a/test/unit/org/apache/cassandra/cql3/validation/entities/SecondaryIndexTest.java b/test/unit/org/apache/cassandra/cql3/validation/entities/SecondaryIndexTest.java
index 9563780..947e8b5 100644
--- a/test/unit/org/apache/cassandra/cql3/validation/entities/SecondaryIndexTest.java
+++ b/test/unit/org/apache/cassandra/cql3/validation/entities/SecondaryIndexTest.java
@@ -1483,8 +1483,8 @@ public class SecondaryIndexTest extends CQLTester
Object udt2 = userType("a", 2);
execute("INSERT INTO %s (k, v) VALUES (?, ?)", 1, set(udt1, udt2));
- assertInvalidMessage("Frozen collections only support full()", "CREATE INDEX idx ON %s (keys(v))");
- assertInvalidMessage("Frozen collections only support full()", "CREATE INDEX idx ON %s (values(v))");
+ assertInvalidMessage("Frozen collections are immutable and must be fully indexed", "CREATE INDEX idx ON %s (keys(v))");
+ assertInvalidMessage("Frozen collections are immutable and must be fully indexed", "CREATE INDEX idx ON %s (values(v))");
String indexName = createIndex("CREATE INDEX ON %s (full(v))");
execute("INSERT INTO %s (k, v) VALUES (?, ?)", 2, set(udt2));
diff --git a/test/unit/org/apache/cassandra/index/CustomIndexTest.java b/test/unit/org/apache/cassandra/index/CustomIndexTest.java
index 7194e06..2b2bb87 100644
--- a/test/unit/org/apache/cassandra/index/CustomIndexTest.java
+++ b/test/unit/org/apache/cassandra/index/CustomIndexTest.java
@@ -186,39 +186,39 @@ public class CustomIndexTest extends CQLTester
" PRIMARY KEY(k,c))");
assertInvalidMessage("Cannot create keys() index on frozen column fmap. " +
- "Frozen collections only support full() indexes",
+ "Frozen collections are immutable and must be fully indexed",
String.format("CREATE CUSTOM INDEX ON %%s(c, keys(fmap)) USING'%s'",
StubIndex.class.getName()));
assertInvalidMessage("Cannot create entries() index on frozen column fmap. " +
- "Frozen collections only support full() indexes",
+ "Frozen collections are immutable and must be fully indexed",
String.format("CREATE CUSTOM INDEX ON %%s(c, entries(fmap)) USING'%s'",
StubIndex.class.getName()));
assertInvalidMessage("Cannot create values() index on frozen column fmap. " +
- "Frozen collections only support full() indexes",
+ "Frozen collections are immutable and must be fully indexed",
String.format("CREATE CUSTOM INDEX ON %%s(c, fmap) USING'%s'", StubIndex.class.getName()));
assertInvalidMessage("Cannot create keys() index on frozen column flist. " +
- "Frozen collections only support full() indexes",
+ "Frozen collections are immutable and must be fully indexed",
String.format("CREATE CUSTOM INDEX ON %%s(c, keys(flist)) USING'%s'",
StubIndex.class.getName()));
assertInvalidMessage("Cannot create entries() index on frozen column flist. " +
- "Frozen collections only support full() indexes",
+ "Frozen collections are immutable and must be fully indexed",
String.format("CREATE CUSTOM INDEX ON %%s(c, entries(flist)) USING'%s'",
StubIndex.class.getName()));
assertInvalidMessage("Cannot create values() index on frozen column flist. " +
- "Frozen collections only support full() indexes",
+ "Frozen collections are immutable and must be fully indexed",
String.format("CREATE CUSTOM INDEX ON %%s(c, flist) USING'%s'", StubIndex.class.getName()));
assertInvalidMessage("Cannot create keys() index on frozen column fset. " +
- "Frozen collections only support full() indexes",
+ "Frozen collections are immutable and must be fully indexed",
String.format("CREATE CUSTOM INDEX ON %%s(c, keys(fset)) USING'%s'",
StubIndex.class.getName()));
assertInvalidMessage("Cannot create entries() index on frozen column fset. " +
- "Frozen collections only support full() indexes",
+ "Frozen collections are immutable and must be fully indexed",
String.format("CREATE CUSTOM INDEX ON %%s(c, entries(fset)) USING'%s'",
StubIndex.class.getName()));
assertInvalidMessage("Cannot create values() index on frozen column fset. " +
- "Frozen collections only support full() indexes",
+ "Frozen collections are immutable and must be fully indexed",
String.format("CREATE CUSTOM INDEX ON %%s(c, fset) USING'%s'", StubIndex.class.getName()));
createIndex(String.format("CREATE CUSTOM INDEX ON %%s(c, full(fmap)) USING'%s'", StubIndex.class.getName()));
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org