cql - SELECT in cassandra where id != null -


how query in cassandra != null columns.

select * tablea id != null; select * tablea name != null; 

then wanted store these values , insert these different table.

i don't think possible cassandra. first of all, cassandra cql doesn't support use of not or not equal operators in clause. secondly, clause can contain primary key columns, , primary key columns not allow null values inserted. wasn't sure secondary indexes though, ran quick test:

create table nulltest (id text primary key, name text); insert nulltest (id,name) values ('1','bob'); insert nulltest (id,name) values ('2',null); 

i have table , 2 rows (one null data):

select * nulltest;   id | name ----+------   2 | null   1 |  bob  (2 rows) 

i try create secondary index on name, know contains null values.

create index nulltestidx on nulltest(name); 

it lets me it. now, i'll run query on index.

select * nulltest name=null; bad request: unsupported null value indexed column name 

and again, done under premise can't query not null, if can't query column values may null.

so, i'm thinking can't done. also, if null values possibility in primary key, may want re-evaluate data model. again, know op's question querying data not null. mentioned before, cassandra cql doesn't have not or != operator, that's going problem right there.

another option, insert empty string instead of null. able query on empty string. still doesn't past fundamental design flaw of having null in primary key field. perhaps if had composite primary key, , part of (the clustering columns) had possibility of being empty (certainly not part of partitioning key). you'd still stuck problem of not being able query rows "not empty" (instead of not null).

note: inserting null values done here demonstration purposes only. should best avoid, inserting null column value create tombstone. likewise, inserting lots of null values create lots of tombstones.


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -