Cassandra 2.1.8上的非冻结集合和用户定义类型

时间:2015-08-11 23:49:28

标签: cassandra cql datastax cql3

我正在尝试从here

运行以下示例
  CREATE TYPE address (
          street text,
          city text,
          zip int
      );

 CREATE TABLE user_profiles (
      login text PRIMARY KEY,
      first_name text,
      last_name text,
      email text,
      addresses map<text, address>
  );

但是,当我尝试创建user_profiles表时,出现以下错误:

InvalidRequest: code=2200 [Invalid query] message="Non-frozen collections are not
allowed inside collections: map<text, address>

有关为何会发生这种情况的任何想法?

3 个答案:

答案 0 :(得分:14)

我正在运行2.1.8并收到相同的错误消息。要解决此问题,您需要frozen关键字:

 CREATE TABLE user_profiles (
      login text PRIMARY KEY,
      first_name text,
      last_name text,
      email text,
      addresses map<text, frozen <address>>
  );
UDT(现在)需要

Frozen,因为它将它们序列化为单个值。您可以使用类似的更好的示例User Defined Type documentation。试一试。

答案 1 :(得分:9)

当我错误地使用&#34; string&#34;时,我收到了这条消息。而不是&#34; text&#34;在卡桑德拉地图中,如:

mymap map<bigint, string> 

我从google跟踪了这个stackoverflow线程,我认为这些信息可以为他们节省几分钟的时间。

答案 2 :(得分:8)

尚不支持非冻结的UDT。要求用户为每个UDT显式指定此关键字的原因是能够在3.x中引入provides a way to work around it而不破坏现有代码。