1

A column in a table is of type float, which is not populated when a row is inserted, i.e. to be populated later. Is there a way to select those rows ?

The cql CLI outputs a value of null.

This was the query I tried.

select * from <table> where <column> is null;

And then followed this CQL: Unable to Null Check in "Where" Clause

i.e. there is no null like thing in cassandra.

Is there a work around for this ?

Community
  • 1
  • 1
M T
  • 4,099
  • 4
  • 21
  • 27

2 Answers2

1

Unfortunately, this is not currently supported. Cassandra interprets null as a lack of a value, as opposed to a special constant. I'm guessing that adding null support to select queries (as well as indexing, partitioning, etc.) would be a major redesign both code-wise and in terms of how data is persisted in tables, hence it is not currently pursued.

For a workaround, I would suggest using a constant value that you would interpret as "null" on the client-side (e.g.: NaN, -Infinity, or something else outside your normal range of values). You'll have to make sure you explicitly initialize appropriate rows with this value, because default values are also currently unsupported.

Daniel S.
  • 3,494
  • 24
  • 30
  • Yeah loads of things are not supported, I am planning to move to mongodb. – M T Feb 18 '14 at 03:25
  • Fair enough. If you don't specifically require Cassandra scalability and perf capabilities, MongoDB may be an easier, more effective solution. – Daniel S. Feb 18 '14 at 04:49
1

Daniel is right that this is not supported yet, but for the wrong reason. :)

Null is actually supported as of 1.2.4, per the link in the original issue. However, unindexed filtered queries like this are still not supported (https://issues.apache.org/jira/browse/CASSANDRA-6377), even with ALLOW FILTERING, because they are out of scope for Cassandra's mission of supporting applications at scale. This kind of query is quite useful while prototyping, but when you have billions of rows, ten of which are null, and unleash this on your cluster you're going to have a bad time.

(Now, if you need to do this as part of analytics at scale, Cassandra points you to our Hadoop integration or DataStax Enterprise.)

That said, we're moving towards the position of, let users do what they want even if it means shooting themselves in the foot. We expect to support this kind of query in 3.0 later in 2014.

jbellis
  • 19,347
  • 2
  • 38
  • 47