9

I guess everybody that played with Cassandra already read this article.

I trying to create my schema on CassandraCli, but I am having a lot of problems, can someone guide me to the right way? I am trying to create a similar structure like the Comments column family from the article.

In CassandraCli terminal I type:

create column family posts with column_type = ‘Super’ and comparator = ‘AsciiType’ and subcomparator = TimeUUIDType;

It works fine, there is no doc telling me that if I add a column_metadata attribute those will be for the super columns cause my column family is of type super, i can’t find if it is true so:

create column family posts with column_type = ‘Super’ and comparator = ‘AsciiType’ and subcomparator = ‘TimeUUIDType’ and column_metadata = [{column_name:'body'}];

I am trying to create the same as the comment column family of the article, but when i try to populate

set posts['post1'][timeuuid()][body] = ‘Hello I am Goku!’;

i got:

Invalid UUID string: body

I guess because i chose the subcomparator be of type timeuuid and the body is a string, it should be a timeuuid, so HOW my columns inside the super column which is the type timeuuid could holds columns with string type names as the comments of the article are created?

Thanks

skaffman
  • 381,978
  • 94
  • 789
  • 754
Laubstein
  • 191
  • 2
  • 5
  • +1 for someone with a rep of 1 asking a question about Cassandra. It's refreshing to see someone interested in something else than SQL... – SyntaxT3rr0r Jan 13 '11 at 23:10

4 Answers4

5

I think you switched what comparator_type and subcomparator_type apply to. In super column families, comparator_type applies to the super column names, and subcombparator_type applies to the subcolumn names.

Switch the comparator types and your first example should work.

Tyler Hobbs
  • 6,637
  • 22
  • 31
1

set posts[1][timeuuid()][utf8('body')] = 'Hello I am Goku!';

The correct answer shall be that.

:p

Xeo
  • 123,374
  • 44
  • 277
  • 381
0

Did you try quoting 'body'?

set posts['post1'][timeuuid()]['body'] = ‘Hello I am Goku!’;
yfeldblum
  • 63,188
  • 11
  • 126
  • 168
0

I tried:

set posts[1][timeuuid()]['body'] = 'Hello I am Goku!';

it worked...

aletapool
  • 303
  • 3
  • 9