0

I am trying to create a user defined type with Cassandra. I am using cqlsh and the example provided in the documentation (http://www.datastax.com/documentation/cql/3.1/cql/cql_reference/cqlRefcreateType.html):

REATE TYPE address (
  street text,
  city text,
  zip_code int,
  phones set<text>
)

But this returns:

Bad Request: line 1:7 no viable alternative at input 'TYPE'

Using the help command, I found the 'CREATE_TABLE_TYPES' but I could not get it to work either.

What is the correcft syntax to get this to work?

Many thanks

Spearfisher
  • 8,445
  • 19
  • 70
  • 124

2 Answers2

1

Looks like you need to create a keyspace first:

cqlsh> CREATE KEYSPACE excelsior
   ...   WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 3 };
cqlsh> use excelsior;
cqlsh:excelsior> CREATE TYPE address (
             ...   street text,
             ...   city text,
             ...   zip_code int,
             ...   phones set<text>
             ... );
catpaws
  • 2,263
  • 16
  • 18
0

I also struck with same problem. User type doesn't supported by earlier version of 2.1. Now i am using 2.1.2 version of cassandra.

You can find it NEW FEATURES of Cassandra

rahul
  • 1,062
  • 5
  • 15
  • 31