0
votes

I'm trying to create a table in CQLSH and then access it in CLI (just to see how to do it). Although this has worked fine for varchar columns, I'm having trouble with int columns.

My column family is created in CSQLSH:

create table user (userid varchar primary key, age int, isactive int);

I then insert a row:

insert into user (userid, age, isactive) values('mj',31,1);

Now I switch over to the CLI and can see the value when I use list or just run "get user['MJ']":

[default@test1] get user['mj'];
=> (column=, value=, timestamp=1369665807675000)
=> (column=age, value=31, timestamp=1369665807675000)
=> (columnisactive, value=1, timestamp=1369665807675000)
Returned 3 results.
Elapsed time: 5.7 msec(s).

But when I try to access the age integer column I get this error:

[default@test1] get user['mj']['age'] as Int32Type;
Not enough bytes to read value of component 0
InvalidRequestException(why:Not enough bytes to read value of component 0)
    at org.apache.cassandra.thrift.Cassandra$get_result.read(Cassandra.java:6592)
    at org.apache.thrift.TServiceClient.receiveBase(TServiceClient.java:78)
    at org.apache.cassandra.thrift.Cassandra$Client.recv_get(Cassandra.java:556)
    at org.apache.cassandra.thrift.Cassandra$Client.get(Cassandra.java:541)
    at org.apache.cassandra.cli.CliClient.executeGet(CliClient.java:729)
    at org.apache.cassandra.cli.CliClient.executeCLIStatement(CliClient.java:216)
    at org.apache.cassandra.cli.CliMain.processStatementInteractive(CliMain.java:210)
    at org.apache.cassandra.cli.CliMain.main(CliMain.java:337)

Please can someone shed some light on this?

1

1 Answers

1
votes

Short answer: don't try to access CQL tables with the CLI (or Thrift APIs in general).

Longer answer: http://www.datastax.com/dev/blog/thrift-to-cql3