cassandra - How to make the query to work? -


i have cassandra version 2.0, , in totally new in it, question... have table t1, columns names: 1,2,3...14 (for simplicity); partitioning key column 1 , 2; clustering key column 3, 1 , 5; need perform following query:

select 1,2,7 t1 2='a'; 

column 2 flag, values repeating. following error:

unable execute cql query: partitioning column 2 cannot restricted because preceding column 1 either not restricted or restricted non-eq relation 

so right way it? need data filtered. thanks.

so, make sure understand schema, have defined table t1:

create table t1 (   1 int,   2 int,   3 int,   ...   14 int,   primary ((1, 2), 3, 1, 5) ); 

correct?

if case, cassandra cannot find data answer cql query:

select 1,2,7 t1 2 = 'a'; 

because query has not provided value column "1", without cassandra cannot compute partition key (which requires, per composite primary key definition, both columns "1" and "2"), , without that, cannot determine on nodes in ring. including "2" in partition key, telling cassandra that data required determine store (and thus, read) data.

for example, given schema, query should work:

select 7 t1 1 = 'x' , 2 = 'a'; 

since providing both values of partition key.

@caleb rockcliffe has advice, though, regarding need other, secondary/supplemental lookup mechanisms if above table definition big part of workload. may need find way first lookup values "1" , "2", then issue query. e.g.:

create table t1_index (   1 int,   2 int,   primary key (1, 2); ); 

given value "1", above provide all of possible "2" values, through can iterate:

select 2 t1_index 1 = 'x'; 

and then, each "1" , "2" combination, can then issue query against table t1:

select 7 t1 1 = 'x' , 2 = 'a'; 

hope helps!


Comments

Popular posts from this blog

html - Styling progress bar with inline style -

java - Oracle Sql developer error: could not install some modules -

How to use autoclose brackets in Jupyter notebook? -