incubator-cassandra-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sergei Petrunia <pser...@askmonty.org>
Subject Varchar indexed column and IN(...)
Date Sat, 22 Sep 2012 18:58:26 GMT
Hello,

Does CQL's IN(...) predicate have the same meaning as SQL's IN(...)? I'm 
asking this, because I get results that I cannot explain:

cqlsh:xpl1> select * from t1 where col2='bar1';
 pk   | col1 | col2
------+------+------
 pk1b | foo1 | bar1
  pk1 | foo1 | bar1
 pk1a | foo1 | bar1
 pk1c | foo1 | bar1

cqlsh:xpl1> select * from t1 where col2 in ('bar1', 'bar2') ;
cqlsh:xpl1> 

The first query shows there are records with col2='bar1'. I would expect the
second query return a superset of what the first query returned. However, it
returns nothing!

If this is intended behavior, could somebody please point me to where this is
documented? 

== Complete example == 
# Repeatable on Cassandra 1.1.4 or 1.1.5:

[cqlsh 2.2.0 | Cassandra 1.1.5 | CQL spec 3.0.0 | Thrift protocol 19.32.0]
Use HELP for help.
cqlsh> 
cqlsh> create keyspace xpl1 WITH strategy_class ='SimpleStrategy' and strategy_options:replication_factor=1;
cqlsh> use xpl1;
cqlsh:xpl1> create table t1 (pk varchar primary key, col1 varchar, col2 varchar);
cqlsh:xpl1> create index t1_c1 on t1(col1);
cqlsh:xpl1> create index t1_c2 on t1(col2);
cqlsh:xpl1> insert into t1  (pk, col1, col2) values ('pk1','foo1','bar1');
cqlsh:xpl1> insert into t1  (pk, col1, col2) values ('pk1a','foo1','bar1');
cqlsh:xpl1> insert into t1  (pk, col1, col2) values ('pk1b','foo1','bar1');
cqlsh:xpl1> insert into t1  (pk, col1, col2) values ('pk1c','foo1','bar1');
cqlsh:xpl1> insert into t1  (pk, col1, col2) values ('pk2','foo2','bar2');
cqlsh:xpl1> insert into t1  (pk, col1, col2) values ('pk3','foo3','bar3');
cqlsh:xpl1> select * from t1 where col2='bar1';
 pk   | col1 | col2
------+------+------
 pk1b | foo1 | bar1
  pk1 | foo1 | bar1
 pk1a | foo1 | bar1
 pk1c | foo1 | bar1

cqlsh:xpl1> select * from t1 where col2 in ('bar1', 'bar2') ;
cqlsh:xpl1> 

BR
 Sergei
-- 
Sergei Petrunia, Software Developer
Monty Program AB, http://askmonty.org
Blog: http://s.petrunia.net/blog

Mime
View raw message