You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cassandra.apache.org by "Hiller, Dean" <De...@nrel.gov> on 2013/11/19 19:38:04 UTC

support for nulls in composite lost in CQL3

We have wide rows which are composite of integer.byte array where some of our columns are {empty}.byte array (ie. The first part of the composite key is empty as in 0 length string or 0 length integer(ie. NOT 0, but basically null)

This has worked great when we look up all the entries with a empty prefix in thrift, but from what I understand, there is no support for this in CQL3?????

Or if there is support, how do I get all the values with an empty prefix in CQL3?

Thanks,
Dean

Re: support for nulls in composite lost in CQL3

Posted by Sylvain Lebresne <sy...@datastax.com>.
> but from what I understand, there is no support for this in CQL3?

Whether or not there is "support" probably depends on your definition of
"support". It is "possible" to do in CQL3 if that is your question.

What can be said however is that CQL3 does not consider that every type
should
have an empty value and so, while it ultimately does support empty values
for
every type (for thrift compatibility sake), it does not encourage them for a
number of types. In particular, numeric types don't have constants to
represent
the empty value (while types that do support empty values naturally do have
easy representation for it, like Ox for the blob type or '' for the text
type).

Anyway, like I said above, there is no easy syntax for it but you can have
empty
values even for numeric types like int. If you use prepared statement, since
those take values as binary, just sending an empty binary value will work
(you
may have to check your client driver to see how to do that though).
But otherwise, the simplest way to get an empty value for say, a int, is
probably
blobAsInt(0x) (that is, the empty blob value 0x but "cast" to an int to make
the type system happy).

> how do I get all the values with an empty prefix in CQL3?

Provided what's above, you'd do something like:
  SELECT * FROM myTable WHERE firstCol=blobAsInt(0x)

--
Sylvain