2
votes

I'm new in Cassandra and I have a trouble inserting some rows in a database getting the error of the title.

I use cassandra 1.0.8 and cqlsh for doing changes in my database.

Next, I explain the given steps before I get the error:

CREATE A COLUMN FAMILY

CREATE TABLE test (
    col1 int PRIMARY KEY,
col2 bigint, 
col3 boolean,
col4 timestamp
);

INSERT SEVERAL ROWS WITHOUT SPECIFICYING ALL OF COLUMNS OF THE TABLE

insert into test (col1, col2, col3) values (1, 100, true);
insert into test (col1, col2, col3) values (2, 200, false);

SELECT FOR CHECKING THAT ROWS HAVE BEEN INSERTED CORRECTLY

select * from test;

The result is the following:

Result of select * from test

INSERT A ROW SPECIFICYING A VALUE FOR THE col4 (NOT SPECIFIED BEFORE)

insert into test (col1, col2, col3, col4) values (3, 100, true, '2011-02-03');

SELECT FOR CHECKING THAT ROW HAS BEEN INSERTED CORRECTLY

select * from test;

In this SELECT is the error. The result is the following:

enter image description here

SELECT EACH COLUMN OF THE TABLE SEPARATELY

select col1 from test;
select col2 from test;
select col3 from test;
select col4 from test;

it works fine and shows the right values:

enter image description here

Then, my question is: what's the problem in the first SELECT? what's wrong?

Thanks in advance!!

NOTE:

If I define col4 as Integer rather than a timestamp it works. However, I've tried to insert col4 as the normalized format yyyy-mm-dd HH:mm (I've tried with '2011-02-03 01:05' and '2011-02-03 01:05:10') but it doesn't work.

2

2 Answers

1
votes

Cassandra 1.0.8 shipped with CQL2 and that's where your problem is coming from. I managed to recreate this in 1.0.8 but it works fine with 1.2.x so my advice is upgrade if you can.

In C* 1.2.10

cqlsh> update db.user set date='2011-02-03 01:05' where user='JCTYpjJlM';
cqlsh> SELECT  * from db.user ;    

 user      | date                     | password
-----------+--------------------------+----------
 xvkYQKerQ |                     null |      765
 JCTYpjJlM | 2011-02-03 01:05:00+0200 |      391
0
votes

@mol

Weird, try to insert col4 as Integer (convert to milliseconds first) or use the normalized format : yyyy-mm-dd HH:mm

Accodring to the doc here, you can omit the time and just input the date but it seems that breaks something in your case