You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cassandra.apache.org by Paul van Hoven <pa...@googlemail.com> on 2013/02/03 00:36:58 UTC

CQL : Date comparison in where clause fails

I've got a table that has a column called date. I created an index on
the column date with the following command:

CREATE INDEX date_key ON ola (date);

Now, I can perform the following command:

select * from ola where date = '2013-01-01' limit 10;

The results are correctly displayed.

But the the following command fails:
cqlsh:demodb> select * from ola where date > '2013-01-01' limit 10;
Bad Request: No indexed columns present in by-columns clause with Equal operator
Perhaps you meant to use CQL 2? Try using the -2 option when starting cqlsh.

The same happens when using
cqlsh:demodb> select * from ola where date >= '2013-01-01' limit 10;
Bad Request: No indexed columns present in by-columns clause with Equal operator
Perhaps you meant to use CQL 2? Try using the -2 option when starting cqlsh.

Why does this happen?

Re: CQL : Date comparison in where clause fails

Posted by Manu Zhang <ow...@gmail.com>.
On Sun 03 Feb 2013 08:19:08 PM CST, Paul van Hoven wrote:
> Thanks for the answer. If I understand that correctly I had to do the
> following to repair my query:
>
> cqlsh:demodb> select * from ola where date < '2013-01-01' and date =
> '2013-01-01' limit 10;
> Bad Request: datum cannot be restricted by more than one relation if
> it includes an Equal
> Perhaps you meant to use CQL 2? Try using the -2 option when starting cqlsh.
>
> So, this still fails. Therefore I'm not shure whether I missunderstand
> the issue or if it does not solve my problem.
>
> 2013/2/3 Manu Zhang <ow...@gmail.com>:
>> On Sun 03 Feb 2013 07:36:58 AM CST, Paul van Hoven wrote:
>>>
>>> I've got a table that has a column called date. I created an index on
>>> the column date with the following command:
>>>
>>> CREATE INDEX date_key ON ola (date);
>>>
>>> Now, I can perform the following command:
>>>
>>> select * from ola where date = '2013-01-01' limit 10;
>>>
>>> The results are correctly displayed.
>>>
>>> But the the following command fails:
>>> cqlsh:demodb> select * from ola where date > '2013-01-01' limit 10;
>>> Bad Request: No indexed columns present in by-columns clause with Equal
>>> operator
>>> Perhaps you meant to use CQL 2? Try using the -2 option when starting
>>> cqlsh.
>>>
>>> The same happens when using
>>> cqlsh:demodb> select * from ola where date >= '2013-01-01' limit 10;
>>> Bad Request: No indexed columns present in by-columns clause with Equal
>>> operator
>>> Perhaps you meant to use CQL 2? Try using the -2 option when starting
>>> cqlsh.
>>>
>>> Why does this happen?
>>
>>
>> because only EQ operator is allowed. There is a similar question in an
>> earlier thread, and as pointed out by Sylvain,
>> https://issues.apache.org/jira/browse/CASSANDRA-4476 may finally solve it.

only EQ is supported for the current so "date < '2013-01-01' will fail. 
I think you could include date into the primary key such that you're 
able to get data after or before a certain date

Re: CQL : Date comparison in where clause fails

Posted by Paul van Hoven <pa...@googlemail.com>.
Thanks for the answer. If I understand that correctly I had to do the
following to repair my query:

cqlsh:demodb> select * from ola where date < '2013-01-01' and date =
'2013-01-01' limit 10;
Bad Request: datum cannot be restricted by more than one relation if
it includes an Equal
Perhaps you meant to use CQL 2? Try using the -2 option when starting cqlsh.

So, this still fails. Therefore I'm not shure whether I missunderstand
the issue or if it does not solve my problem.

2013/2/3 Manu Zhang <ow...@gmail.com>:
> On Sun 03 Feb 2013 07:36:58 AM CST, Paul van Hoven wrote:
>>
>> I've got a table that has a column called date. I created an index on
>> the column date with the following command:
>>
>> CREATE INDEX date_key ON ola (date);
>>
>> Now, I can perform the following command:
>>
>> select * from ola where date = '2013-01-01' limit 10;
>>
>> The results are correctly displayed.
>>
>> But the the following command fails:
>> cqlsh:demodb> select * from ola where date > '2013-01-01' limit 10;
>> Bad Request: No indexed columns present in by-columns clause with Equal
>> operator
>> Perhaps you meant to use CQL 2? Try using the -2 option when starting
>> cqlsh.
>>
>> The same happens when using
>> cqlsh:demodb> select * from ola where date >= '2013-01-01' limit 10;
>> Bad Request: No indexed columns present in by-columns clause with Equal
>> operator
>> Perhaps you meant to use CQL 2? Try using the -2 option when starting
>> cqlsh.
>>
>> Why does this happen?
>
>
> because only EQ operator is allowed. There is a similar question in an
> earlier thread, and as pointed out by Sylvain,
> https://issues.apache.org/jira/browse/CASSANDRA-4476 may finally solve it.

Re: CQL : Date comparison in where clause fails

Posted by Manu Zhang <ow...@gmail.com>.
On Sun 03 Feb 2013 07:36:58 AM CST, Paul van Hoven wrote:
> I've got a table that has a column called date. I created an index on
> the column date with the following command:
>
> CREATE INDEX date_key ON ola (date);
>
> Now, I can perform the following command:
>
> select * from ola where date = '2013-01-01' limit 10;
>
> The results are correctly displayed.
>
> But the the following command fails:
> cqlsh:demodb> select * from ola where date > '2013-01-01' limit 10;
> Bad Request: No indexed columns present in by-columns clause with Equal operator
> Perhaps you meant to use CQL 2? Try using the -2 option when starting cqlsh.
>
> The same happens when using
> cqlsh:demodb> select * from ola where date >= '2013-01-01' limit 10;
> Bad Request: No indexed columns present in by-columns clause with Equal operator
> Perhaps you meant to use CQL 2? Try using the -2 option when starting cqlsh.
>
> Why does this happen?

because only EQ operator is allowed. There is a similar question in an 
earlier thread, and as pointed out by Sylvain, 
https://issues.apache.org/jira/browse/CASSANDRA-4476 may finally solve 
it.