[
https://issues.apache.org/jira/browse/CASSANDRA-11310?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15187081#comment-15187081
]
Benjamin Lerer commented on CASSANDRA-11310:
--------------------------------------------
{{`(b_yr, b_mon) > ('2015', '06')`}} will work. By carefull it is different
from {{`b_yr > '2015' AND b_mon > '06'}}.
You can have a look
[here|http://www.datastax.com/dev/blog/a-deep-look-to-the-cql-where-clause#comment-3232485].
Hopefully, it should help you to understand the difference. To be honest, I
also sometime get confused :-).
Your analysis is right, the problem will happen everytime you have a
restriction after a slice. So for example:
* {{SELECT * FROM myTable WHERE clustering2 = 1 ALLOW FILTERING}} or {{SELECT
* FROM myTable WHERE clustering2 > 1 ALLOW FILTERING}} where the slice is due
to the fact that clustering1 is not restricted
* {{SELECT * FROM myTable WHERE clustering1 = 1 AND clustering3 = 1 ALLOW
FILTERING}} or {{SELECT * FROM myTable WHERE clustering1 = 1 AND clustering2 >
1 ALLOW FILTERING}} where the slice is due to the fact that clustering2 is
not restricted
* {{SELECT * FROM myTable WHERE clustering1 > 0 AND clustering2 = 1 ALLOW
FILTERING}} or {{SELECT * FROM myTable WHERE clustering1 > 0 AND clustering2 >
1 ALLOW FILTERING}} where the slice is caused by the {{>}} operator.
I guess that the problem will also happen for {{CONTAINS}} and {{CONTAINS KEY}}
restrictions as they cannot be used to build a {{Clustering}} but can be used
to filter.
Which means that queries like {{SELECT * FROM myTable WHERE clustering1
CONTAINS 1 ALLOW FILTERING}} and {{SELECT * FROM myTable WHERE clustering1 = 0
AND clustering2 CONTAINS 1 ALLOW FILTERING}} should also be supported.
> Allow filtering on clustering columns for queries without secondary indexes
> ---------------------------------------------------------------------------
>
> Key: CASSANDRA-11310
> URL: https://issues.apache.org/jira/browse/CASSANDRA-11310
> Project: Cassandra
> Issue Type: Improvement
> Components: CQL
> Reporter: Benjamin Lerer
> Assignee: Alex Petrov
> Labels: doc-impacting
> Fix For: 3.x
>
>
> Since CASSANDRA-6377 queries without index filtering non-primary key columns
> are fully supported.
> It makes sense to also support filtering on clustering-columns.
> {code}
> CREATE TABLE emp_table2 (
> empID int,
> firstname text,
> lastname text,
> b_mon text,
> b_day text,
> b_yr text,
> PRIMARY KEY (empID, b_yr, b_mon, b_day));
> SELECT b_mon,b_day,b_yr,firstname,lastname FROM emp_table2
> WHERE b_mon='oct' ALLOW FILTERING;
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)