I see many examples on here that create tables using the NOT NULL constraint. Ironically I can't seem to do the same.
This is the cql command I use :
CREATE TABLE activities_dev (activity_id uuid ,actor_id bigint NOT NULL, actor_appid bigint NOT NULL, item_id text NOT NULL, verb text NOT NULL,viewer_id bigint NOT NULL,viewer_appid bigint NOT NULL, ts timestamp, PRIMARY KEY(activity_id,actor_id,actor_appid,item_id,verb));
but this is the error I get:
SyntaxException: line 1:62 mismatched input 'NOT' expecting ')' (...activities_dev(activity_id uuid, actor_id integer [NOT] NULL...)
What am I doing wrong ?
In Cassandra NOT NULL keyword not supported.
For primary key columns cassandra automatically handle that. If you try to insert null to any primary key value cassandra will throw exception
Invalid null value in condition for column
Null column in Cassandra does not mean empty column.
Cassandra uses nulls for marking deleted columns : you can delete one or several columns of a row in Cassandra.
This timestamped marker called tombstone is used for data reconciliation locally and between nodes (Commitlog, memtables, SStables) and in replicated keyspaces prevents resurrection of data (see this article for example about replicated deleted).
In this context, it makes sense not to allow a 'NOT NULL' clause in CREATE TABLE and ALTER TABLE CQL syntax.
Alain
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With