[ 
https://issues.apache.org/jira/browse/CASSANDRA-11310?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15187256#comment-15187256
 ] 

Benjamin Lerer commented on CASSANDRA-11310:
--------------------------------------------

{quote}I hope I'm not bugging you with questions too much.{quote}

Not at all. :-)

{quote}It looks like it all requires changes to MultiCBuilder, since at the 
moment only a single slice is allowed, and it always has to be the "last" one, 
as either buildBoundForSlice or buildBound is returned in 
PrimaryKeyRestrictionSet::boundsAsClustering. At least for the cases with 
slices over multiple columns, such as SELECT * FROM myTable WHERE b < 3 AND c 
<= 4.{quote}

{{MultiCBuilder}} is used to build the {{Clustering}} or the {{Slice.Bound}}. I 
do not think that you need to change it. The way the rows are selected based on 
their clustering columns should stay the same. What will change is the fact 
that the selected rows will be filtered out afterwards. What you need to do is 
to make sure that the columns that should be used for the filtering are not 
used for computing the {{Clustering}} set and the {{Slice.Bound}} set (and 
ideally that the clustering columns that are not used for the filtering are not 
used to build {{RowFilter.Expression}}).

Basically, it is a 2 step process: first we select the rows or range of rows 
that match the specifed {{Clustering}} or {{Slice.Bound}} sets, then we filter 
the selected rows using the remaining restrictions. The first part of the 
process rely on the  {{PrimaryKeyRestrictionSet::valuesAsClustering}} and 
{{PrimaryKeyRestrictionSet::boundsAsClustering methods}}. The second part of 
the process rely on the {{PrimaryKeyRestrictionSet::addRowFilterTo}} method.

> 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)

Reply via email to