DataStax Academy FAQ

DataStax Academy migrated to a new learning management system (LMS) in July 2020. We are also moving to a new Cassandra Certification process so there are changes to exam bookings, voucher system and issuing of certificates.

Check out the Academy FAQ pages for answers to your questions:


question

synedra avatar image
synedra asked ·

Why can't I insert data into a timeuuid column?

I'm working through the Datastax Academy courses, and I'm supposed to make a Keyspace (done) and then a table, so I did:

CREATE TABLE videos (
  video_id timeuuid PRIMARY KEY,
  added_date timestamp,
  title text
)

But then I try to insert information and it doesn't work:

INSERT INTO videos ( 1645EA59-14BD-11ES-A993-8138354B7E31, '2014-01-29', 'Cassandra History')
... ;
SyntaxException: line 1:38 mismatched character 'S' expecting set null

Help?

It looks like a valid timeuuid to me but I guess I must be missing something. Tried lowercasing and it didn't help.

cql
10 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

1 Answer

cedrick.lunven_137390 avatar image
cedrick.lunven_137390 answered ·

Hi @synedra, thank you for your question.


There are things we can improve in your table design :

If the added_date is expected to be formatted as 'YYYY-MM-DD' you can use CQL type date.

It would look like

CREATE TABLE IF NOT EXISTS videos ( 
  video_id timeuuid PRIMARY KEY, 
  added_date date, 
  title text );


To insert values as timeuuid you can only have hexadecimal characters, you should change the s with a 5 for instance, try this. You can also use function now() to have current time.

INSERT INTO videos(video_id, added_date, title) VALUES (50554d6e-29bb-11e5-b345-feff819cdc9f, '2014-01-29', 'Cassandra History');
INSERT INTO videos(video_id, added_date, title) VALUES (now() '2014-01-29', 'Cassandra History');
1 comment Share
10 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Thanks! I had incorrectly copied the string from one of the tutorials in the Academy tutorials :-)

0 Likes 0 ·