2
votes

Anybody please help me understand why Cassandra is inserting null values in columns that was skipped? Isn't it supposed to skip the column? It should not insert any value (not even null) if I skip the column entirely while inserting data? I am bit confused because as per the following tutorial, data is stored by row key with the columns (the diagram in column family), if it is true then I should not get null for the column.

Or the whole concept I learned about the Cassandra column family is wrong?

http://www.tutorialspoint.com/cassandra/cassandra_data_model.htm

Here is the CQL script

create keyspace test WITH replication =  {'class': 'SimpleStrategy',   'replication_factor': '1'};
create table users (firstname text,lastname text,age int, gender ascii, primary key(firstname))
insert into users(firstname,age,gender,lastname) values("Michael",30,"male","smith");

Here, I am skipping a column, but when I run select query, it shows null for that column. Why Cassandra is filling up null in that column?

insert into users(firstname,age,gender) values('Jane',23,'female');

select * from users;
1

1 Answers

1
votes
  1. Why don't you go to the most comprehensive source of documentation and learning for Cassandra : http://academy.datastax.com ? And it's free. The content and tutorialspoint.com is very old and not updated since ages (SuperColumn are deprecated since 2011 - 2012 ...)

  2. Here, I am skipping a column, but when I run select query, it shows null for that column. Why Cassandra is filling up null in that column?

In CQL, null == value is not present or value has been deleted

Since you did not insert any value for column lastname Cassandra will return null (== not present in this case)