18

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:

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?

Alex Ott
  • 80,552
  • 8
  • 87
  • 132
userNotFound
  • 347
  • 1
  • 4
  • 13

3 Answers3

18

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

 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.

Aaron
  • 55,518
  • 11
  • 116
  • 132
11

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

mymap map<bigint, string> 

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

Soid
  • 2,585
  • 1
  • 30
  • 42
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.

Stefan Podkowinski
  • 5,206
  • 1
  • 20
  • 25
  • Thanks for clarifying that, Stefan! I thought it was specific to collections; so I've fixed my answer as well. – Aaron Aug 12 '15 at 08:59