hi, everyone, I'm learning Cassandra now , and have some problems about the 
document of "Data Types" .  I don't know where to report or ask for help, so 
I'm very sorry if this mail bother you.

In the chapter The Cassandra Query Language (CQL)/Data Types 
(http://cassandra.apache.org/doc/latest/cql/types.html), I'm confused with two 
examples the document showing below. My enviroment is:

CentOS release 6.8 (Final)

java version "1.8.0_91"
Java(TM) SE Runtime Environment (build 1.8.0_91-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.91-b14, mixed mode)

Python 2.7.11

Cassandra version: 3.7
CQL version: [cqlsh 5.0.1 | Cassandra 3.7 | CQL spec 3.4.2 | Native protocol v4]


1、 in http://cassandra.apache.org/doc/latest/cql/types.html, when describing 
type set, the giving example is:
CREATE TABLE images (
    name text PRIMARY KEY,
    owner text,
    tags set<text> // A set of text values
);
INSERT INTO images (name, owner, tags)
            VALUES ('cat.jpg', 'jsmith', { 'pet', 'cute' });
// Replace the existing set entirely
UPDATE images SET tags = { 'kitten', 'cat', 'lol' } WHERE id = 'jsmith';
the update cql statement uses "WHERE id = 'jsmith'" while the table images did 
not define key "id". I think it's just a slip of the pen.

2、 in http://cassandra.apache.org/doc/latest/cql/types.html, when describing 
“User-Defined Types”,  the giving example is:
    CREATE TYPE phone (
    country_code int,
    number text,
)
CREATE TYPE address (
    street text,
    city text,
    zip int,
    phones map<text, phone>
)
CREATE TABLE user (
    name text PRIMARY KEY,
    addresses map<text, frozen<address>>
)
and when I try to create type address, one error occur:

cqlsh:counterks> CREATE TYPE address (
             ...     street text,
             ...     city text,
             ...     zip int,
             ...     phones map<text, phone>
             ... );
InvalidRequest: code=2200 [Invalid query] message="Non-frozen UDTs are not 
allowed inside collections: map<text, phone>"

I change the create statement, like:

CREATE TYPE address (
    street text,
    city text,
    zip int,
    phones map<text, frozen<phone>>
);

it works, and the create table user statement works well. Unfortunately, when 
running the insert statement below, error occur:
INSERT INTO user (name, addresses)
          VALUES ('z3 Pr3z1den7', {
              'home' : {
                  street: '1600 Pennsylvania Ave NW',
                  city: 'Washington',
                  zip: '20500',
                  phones: { 'cell' : { country_code: 1, number: '202 456-1111' 
},
                            'landline' : { country_code: 1, number: '...' } }
              }
              'work' : {
                  street: '1600 Pennsylvania Ave NW',
                  city: 'Washington',
                  zip: '20500',
                  phones: { 'fax' : { country_code: 1, number: '...' } }
              }
          })
error:
SyntaxException: <ErrorMessage code=2000 [Syntax error in CQL query] 
message="line 10:14 mismatched input 'work' expecting '}' (...: '...' } }       
       }              ['wor]k' :...)">

 Is the any suggestion about the problem 2?

Best wishes for everyone, thank you for your watching !



zha...@easemob.com

Reply via email to