Bringing together the Apache Cassandra experts from the community and DataStax.

Want to learn? Have a question? Want to share your expertise? You are in the right place!

Not sure where to begin? Getting Started

 

question

bb.addagada_90355 avatar image
bb.addagada_90355 asked ·

How can I add blank values instead of null values in cassandra ?

We are using DSE 5.1.0 & Spring boot Java.

While we are trying to insert data into cassandra , java by default inserts null values in cassandra tables which is causing huge tombstones.

Instead of changing code in java to insert null values, can you control anywhere at driver level ?

tombstones
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

seandurity_18889 avatar image
seandurity_18889 answered ·

Beware of CQL generators, like Spring Data Cassandra. The more proper insert is to only insert columns that have values. I think the null generation is in the Spring Data framework, not Java.

Good: insert into my_table (key, columna, columnb) values ('my_id','text A','text B');

--don't include columnc, columnd if there are no values. Nulls create tombstones and will delete any values previously inserted for those columns

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.