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

时间:2020-12-22 16:27:59

I'm trying to run the following example from 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>
  );

However, when I try to create the user_profiles table, I get the following error:

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

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

Any thoughts on why this could be happening?

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

3 个解决方案

#1


13  

I am running 2.1.8 and I get the same error message. To fix this, you need the frozen keyword:

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

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

Frozen is necessary for UDTs (for now) as it serializes them into a single value. A similar, better example for you to follow might be the one in the User Defined Type documentation. Give that a try.

冻结是UDT(现在)必需的,因为它将它们序列化为单个值。您可以使用类似的更好的示例,即用户定义类型文档中的示例。试一试。

#2


8  

Non-frozen UDTs are not yet supported. The reason for asking the user to explicitly specify this keyword for each UDT is to be able to introduce mutable UDTs in 3.x without breaking existing code.

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

#3


7  

I was getting this message when I mistakenly used "string" instead of "text" in a cassandra map, like:

当我错误地在cassandra地图中使用“string”而不是“text”时,我收到此消息,如:

mymap map<bigint, string> 

I followed this * thread from google and I thought this information could save someone a few minutes of their time.

我从谷歌跟踪这个*线程,我认为这些信息可以节省一些时间的人。

#1


13  

I am running 2.1.8 and I get the same error message. To fix this, you need the frozen keyword:

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

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

Frozen is necessary for UDTs (for now) as it serializes them into a single value. A similar, better example for you to follow might be the one in the User Defined Type documentation. Give that a try.

冻结是UDT(现在)必需的,因为它将它们序列化为单个值。您可以使用类似的更好的示例,即用户定义类型文档中的示例。试一试。

#2


8  

Non-frozen UDTs are not yet supported. The reason for asking the user to explicitly specify this keyword for each UDT is to be able to introduce mutable UDTs in 3.x without breaking existing code.

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

#3


7  

I was getting this message when I mistakenly used "string" instead of "text" in a cassandra map, like:

当我错误地在cassandra地图中使用“string”而不是“text”时,我收到此消息,如:

mymap map<bigint, string> 

I followed this * thread from google and I thought this information could save someone a few minutes of their time.

我从谷歌跟踪这个*线程,我认为这些信息可以节省一些时间的人。