incubator-cassandra-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aaron morton <aa...@thelastpickle.com>
Subject Re: CQL query issue when fetching data from Cassandra
Date Thu, 16 Feb 2012 09:05:24 GMT
> 1). The "IN" operator is not working
>     SELECT * FROM TestCF WHERE status IN ('Failed', 'Success')
IN is only valid for filtering on the row KEY
http://www.datastax.com/docs/1.0/references/cql/SELECT

e.g. it generates this error using cqlsh
cqlsh:dev> SELECT * FROM TestCF WHERE status IN ('Failed', 'Success');
Bad Request: Expected key 'KEY' to be present in WHERE clause for 'TestCF'

> 2) The "OR" operator is not fetching data.
>    SELECT * FROM TestCF WHERE status='Failed' OR status='Success'
Not a valid statement 
cqlsh:dev> SELECT * FROM TestCF WHERE status='Failed' OR status='Success';
Bad Request: line 1:45 mismatched input 'OR' expecting EOF

> 3) If I use "AND" operator, it also not sending data. Query doesn't have
> issues, but result set is null.
>    SELECT * FROM TestCF WHERE status='Failed' AND status='Success'

cqlsh:dev> SELECT * FROM TestCF WHERE status='Failed' AND status='Success';
Bad Request: cannot parse 'Failed' as hex bytes

Because the CF definition says the status column should contain bytes not ascii. 

These restrictions on secondary indexes still hold
http://www.datastax.com/docs/0.7/data_model/secondary_indexes

it looks like you are implementing a relational model. You may get some value is trying an
approach that uses less secondary CF's. 

Cheers

-----------------
Aaron Morton
Freelance Developer
@aaronmorton
http://www.thelastpickle.com

On 16/02/2012, at 6:58 PM, Roshan wrote:

> Hi
> 
> I am using Cassandra 1.0.6 version and having one column family in my
> keyspace.
> 
> create column family TestCF
>    with comparator = UTF8Type
>    and column_metadata = [
> 	{column_name : userid,
>        validation_class : BytesType,
>        index_name : userid_idx,
>        index_type : KEYS},
> 	{column_name : workspace,
>        validation_class : BytesType,
>        index_name : wp_idx,
>        index_type : KEYS},
> 	{column_name : module,
>        validation_class : BytesType,
>        index_name : module_idx,
>        index_type : KEYS},
> 	{column_name : action,
>        validation_class : BytesType,
>        index_name : action_idx,
>        index_type : KEYS},
> 	{column_name : description,
>        validation_class : BytesType},
> 	{column_name : status,
>        validation_class : BytesType,
>        index_name : status_idx,
>        index_type : KEYS},
> 	{column_name : createdtime,
>        validation_class : BytesType},
> 	{column_name : created,
>        validation_class : BytesType,
>        index_name : created_idx,
>        index_type : KEYS},
> 	{column_name : logdetail,
>        validation_class : BytesType}]
>    and keys_cached = 10000
>    and rows_cached = 1000
>    and row_cache_save_period = 0
>    and key_cache_save_period = 3600
>    and memtable_throughput = 255
>    and memtable_operations = 0.29;
> 
> 1). The "IN" operator is not working
>     SELECT * FROM TestCF WHERE status IN ('Failed', 'Success')
> 2) The "OR" operator is not fetching data.
>    SELECT * FROM TestCF WHERE status='Failed' OR status='Success'
> 3) If I use "AND" operator, it also not sending data. Query doesn't have
> issues, but result set is null.
>    SELECT * FROM TestCF WHERE status='Failed' AND status='Success'
> 4) Is there any thing similar to "LIKE" in CQL? I want to search data based
> on some part of string.
> 
> Could someone please help me to solve the above issues? Thanks.
> 
> 
> 
> --
> View this message in context: http://cassandra-user-incubator-apache-org.3065146.n2.nabble.com/CQL-query-issue-when-fetching-data-from-Cassandra-tp7290072p7290072.html
> Sent from the cassandra-user@incubator.apache.org mailing list archive at Nabble.com.


Mime
View raw message