null values vs undefined values and mapping to java

70 views
Skip to first unread message

Kevin Burton

unread,
Jun 20, 2014, 9:38:23 PM6/20/14
to java-dri...@lists.datastax.com
How does the java driver map to undefined vs null values.

In cassandra a column is just null if it's missing a value.

but some types, like ints, don't support null,  While strings do...

so if your type is an int... and row.isNull() returns true, you know that the value is not defined. 

But strings, null is a totally reasonable value (or some would say) , so when you see null, you're not really sure what happened.

Did someone SET it to null?  

For schema with required fields, that's easy to figure out, but what about optional fields?

... hopefully you guys have an elegant solution to this one because I don't :-P

DuyHai Doan

unread,
Jun 21, 2014, 10:10:31 AM6/21/14
to java-dri...@lists.datastax.com
Null value in the CQL3 semantics means "absent/ has been deleted".

 So when you call row.isNull("myString") and it returns true, it means:

1) either the column "myString" has never been inserted 
2) or the column has been inserted then removed afterward (presence of tombstone)

 Now, talking about mapping null semantics from Java into CQL3 it's an old debate. There is no easy straightforward solution. Some people suggested default "sensible" values for each data type to stand for "null" (empty "" for String, Long.MIN_VALUE for Long ...) but it did not seem consistent enough to make its way into specs
Reply all
Reply to author
Forward
0 new messages