Reputation: 662
Question - I am able to retrieve results with a select statement on a non-existent column value in CQL2 (this does not happen in CQL3 however); can someone explain this to me ?
Do you understand why I would get a result on my select query with a non existent C0 column value ('test') ? I don’t get it – see below: There must be something misconfigured, but what ?
cqlsh> use Keyspace1;
cqlsh:Keyspace1> CREATE COLUMNFAMILY users (
... KEY varchar PRIMARY KEY,
... gender varchar,
... birth_year bigint);
cqlsh:Keyspace1> INSERT INTO users (KEY, gender, birth_year) VALUES ('TEST', 'm', 1968);
cqlsh:Keyspace1> select * from users;
KEY | birth_year | gender
------+------------+--------
TEST | 1968 | m
cqlsh:Keyspace1> select * from users where key = 'TEST';
KEY | birth_year | gender
------+------------+--------
TEST | 1968 | m
cqlsh:Keyspace1> CREATE INDEX birth_year_key ON users (birth_year);
cqlsh:Keyspace1> CREATE INDEX gender_key ON users (gender);
cqlsh:Keyspace1> select * from users where key = 'TEST' and birth_year = 1968;
KEY | birth_year | gender
------+------------+--------
TEST | 1968 | m
cqlsh:Keyspace1> select * from users where birth_year = 1968;
KEY | birth_year | gender
------+------------+--------
TEST | 1968 | m
so far, so good, but now watch:
cqlsh:Keyspace1> select * from users where key = 'TEST' and birth_year = 1962;
KEY | birth_year | gender
------+------------+--------
TEST | 1968 | m
What is going on, here ? Thanks, Matt
Upvotes: 2
Views: 231
Reputation: 19377
Sounds like a bug in CQL2 to me.
Here's the thing: basically the only reason CQL2 is still around is so that the few applications written against it continue to work. No new features will be added and no bugs will be fixed (because that might cause regressions elsewhere).
So if you are building a new application you should absolutely use CQL3. Don't think of CQL2 as an alternative in any meaningful sense of the word. See http://www.datastax.com/dev/blog/cql3-for-cassandra-experts for a detailed breakdown of the shortcomings of CQL2 that drove us to create CQL3 as a replacement.
Upvotes: 2