[jira] [Commented] (CASSANDRA-11310) Allow filtering on clustering columns for queries without secondary indexes

2016-04-19 Thread Sam Tunnicliffe (JIRA)

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

Sam Tunnicliffe commented on CASSANDRA-11310:
-

LGTM, modulo 2 minor nits which I can fix on commit.
* the message {{Cannot restrict clustering columns by a CONTAINS relation 
without a secondary index}} is not strictly true now, as the same is also 
permitted with {{ALLOW FILTERING}}
* the new test method in {{SelectTest}} has a typo in its name and another in 
the issue # it refers to in the comment.




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


[jira] [Commented] (CASSANDRA-11310) Allow filtering on clustering columns for queries without secondary indexes

2016-04-19 Thread Alex Petrov (JIRA)

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

Alex Petrov commented on CASSANDRA-11310:
-

tests are now done, in dtests {{replication_test}} from dtest and 
{{BatchlogManagerTest}} are both passing locally..

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


[jira] [Commented] (CASSANDRA-11310) Allow filtering on clustering columns for queries without secondary indexes

2016-04-18 Thread Alex Petrov (JIRA)

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

Alex Petrov commented on CASSANDRA-11310:
-

I've found one place where {{ALLOW FILTERING}} discards 
{{usesSecondaryIndexing}} in {{StatementRestrictions}}: in 
{{processClusteringColumnRestrictions}} when checking for 
{{clusteringColumns}}. 

>From the example given by Sam: 

{code}
createTable("CREATE TABLE %s (a text, b int, c text, d int, PRIMARY KEY (a, b, 
c));");
execute("CREATE CUSTOM INDEX ON %s (inber) USING 
'org.apache.cassandra.index.sasi.SASIIndex'");

execute("SELECT * FROM %s WHERE a='R1' AND b > 0 AND c = 'int1' ALLOW FILTERING 
;");
{code}

in {{processClusteringColumnRestrictions}} we're checking only the order of 
columns: if the columns are out of order, we set {{usesSecondaryIndexing}}. 
Although that's not the only case. If {{b}} is restricted with slice and {{c}} 
with {{EQ}}, the order is technically correct (both {{b}} and {{c}} are 
restricted), although since {{b}} is restricted with slice, we have to set the 
{{usesSecondaryIndexing}} to true.

I've implemented a fast prototype locally and it seems to fit both cases. I can 
make it prettier and show tomorrow morning.

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


[jira] [Commented] (CASSANDRA-11310) Allow filtering on clustering columns for queries without secondary indexes

2016-04-18 Thread Benjamin Lerer (JIRA)

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

Benjamin Lerer commented on CASSANDRA-11310:


[~beobal] The patch should not have changed the secondary indices behavior. 
Sorry for that. 
I think that the problem will probably not be too difficult to fix. In which 
case it might not be worth it to revert the change.
>From what I can see in the code, it seems that for single or multi partition 
>queries where {{ALLOW FILTERING}} has been specified in the query and where 
>the indexed column is a clustering one 
>{{StatementRestrictions::usesSecondaryIndexing}} will not be set properly. 
 

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


[jira] [Commented] (CASSANDRA-11310) Allow filtering on clustering columns for queries without secondary indexes

2016-04-15 Thread Benjamin Lerer (JIRA)

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

Benjamin Lerer commented on CASSANDRA-11310:


Thanks for the patch.

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


[jira] [Commented] (CASSANDRA-11310) Allow filtering on clustering columns for queries without secondary indexes

2016-04-11 Thread Alex Petrov (JIRA)

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

Alex Petrov commented on CASSANDRA-11310:
-

Added DTests in similar manner to: 
https://github.com/riptano/cassandra-dtest/pull/921 (on clustering, static 
columns with and without compact storage)

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


[jira] [Commented] (CASSANDRA-11310) Allow filtering on clustering columns for queries without secondary indexes

2016-04-08 Thread Benjamin Lerer (JIRA)

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

Benjamin Lerer commented on CASSANDRA-11310:


The patch looks good to me.
Could you add some DTests similar to 
https://github.com/riptano/cassandra-dtest/blob/master/paging_test.py#L941 to 
test filtering on clustering columns with paging?


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


[jira] [Commented] (CASSANDRA-11310) Allow filtering on clustering columns for queries without secondary indexes

2016-04-07 Thread Alex Petrov (JIRA)

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

Alex Petrov commented on CASSANDRA-11310:
-

And the test results:

|[testall|https://cassci.datastax.com/view/Dev/view/ifesdjeen/job/ifesdjeen-11310-trunk-testall/]|[dtest|https://cassci.datastax.com/view/Dev/view/ifesdjeen/job/ifesdjeen-11310-trunk-dtest/]|
 

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


[jira] [Commented] (CASSANDRA-11310) Allow filtering on clustering columns for queries without secondary indexes

2016-04-03 Thread Alex Petrov (JIRA)

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

Alex Petrov commented on CASSANDRA-11310:
-

I've found one problem. It turns out that the restrictions I specified were a 
bit too strict and under several scenarios (for example, when PK is restricted 
with EQ and there are two slices, although both slices have same first column) 
were involving filtering even though they shouldn't have. One other scenario 
was handled incorrectly because the position counter was never updated. 

With Frozen collection tests - it's just missed cases that previously were 
disallowed.

I've pushed (unsquashed to make it easier to trace changes) commits here: 
https://github.com/ifesdjeen/cassandra/commits/11310-trunk

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


[jira] [Commented] (CASSANDRA-11310) Allow filtering on clustering columns for queries without secondary indexes

2016-04-01 Thread Benjamin Lerer (JIRA)

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

Benjamin Lerer commented on CASSANDRA-11310:


|[utest|http://cassci.datastax.com/view/Dev/view/blerer/job/blerer-11310-trunk-testall/1/]|[dtest|http://cassci.datastax.com/view/Dev/view/blerer/job/blerer-11310-trunk-dtest/]|

Some unit tests are failing due to the changes. Could you check what are the 
problems?
The DTest failures seems unrelated.

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


[jira] [Commented] (CASSANDRA-11310) Allow filtering on clustering columns for queries without secondary indexes

2016-03-31 Thread Benjamin Lerer (JIRA)

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

Benjamin Lerer commented on CASSANDRA-11310:


Thanks the changes look good. 
Waiting for CI results.

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


[jira] [Commented] (CASSANDRA-11310) Allow filtering on clustering columns for queries without secondary indexes

2016-03-23 Thread Alex Petrov (JIRA)

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

Alex Petrov commented on CASSANDRA-11310:
-

I hope this time it should be a bit better. 

Unfortunately, making a {{useFiltering}} boolean variable similar to 
{{usesSecondaryIndexing}} would mean splitting some logic within 
{{StatementRestrictions::needFiltering}} into several places and adding several 
iterations (for example check for whether clustering columns cause indexing and 
whether adding the contains restriction would cause filtering).

Although other than that  - there was one redundant check (for 
{{usesSecondaryIndexing || clusteringColumnRestrictions}} that already happens 
in {{processClusteringColumnRestrictions}}). Clustering column restrictions are 
added without influencing indexing flag now, as {{needFiltering}} is now on 
{{ClusteringColumnRestrictions}}.

I've added test covering {{ORDER}}, {{COMPACT}}, {{static}} columns, overall 
in/across partitions, with different combinations of slices, with frozen 
collections in PK.
New branch is here: https://github.com/ifesdjeen/cassandra/commits/11310-trunk

Thank you.

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


[jira] [Commented] (CASSANDRA-11310) Allow filtering on clustering columns for queries without secondary indexes

2016-03-21 Thread Benjamin Lerer (JIRA)

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

Benjamin Lerer commented on CASSANDRA-11310:


I agree that things should be simpler on top of my branch, feel free to use it. 

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


[jira] [Commented] (CASSANDRA-11310) Allow filtering on clustering columns for queries without secondary indexes

2016-03-19 Thread Tyler Hobbs (JIRA)

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

Tyler Hobbs commented on CASSANDRA-11310:
-

bq.  In processClusteringColumnsRestrictions the fact that we set 
useSecondaryIndex to true if we allow filtering does not make sense. I am also 
not sure why we do it for views (Tyler Hobbs is there a good reason?).

I think you're just asking me about views here, so I'll answer that.  The 
{{forView}} flag here indicates that it's a internal query used to populate a 
view (or subsequently filter individual rows).  We're more lenient about what 
we'll accept for these internal queries, because the normal performance 
implications don't really apply.

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


[jira] [Commented] (CASSANDRA-11310) Allow filtering on clustering columns for queries without secondary indexes

2016-03-19 Thread Benjamin Lerer (JIRA)

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

Benjamin Lerer commented on CASSANDRA-11310:


While reviewing your latest patch I realized that it is important to make sure 
that {{usesSecondaryIndexing}} is properly set as it influences the way 
{{SelectStatement}} will process the queries. It seems that it is already wrong 
today. If a query try to perform filtering with a {{CONTAINS}} on a non-primary 
key column, {{SelectStatement}} will believe that an index is used even if it 
is not the case. The query will be executed but not necessarily in the expected 
way and the order by clause will be rejected :-(.

To make the code consistent I believe that {{StatementRestrictions}} should 
have an {{useFiltering}} boolean variable, similar to 
{{usesSecondaryIndexing}}, to keep tract of the fact that the query will 
perform filtering. It might be nice to expose it and have a test in 
{{SelectStatement::getRowFilter}} to return an empty {{RowFilter}} if neither 
filtering nor secondary indices are used.

I do not think that the {{allowFiltering}} variable need to be stored as a 
field in {{StatementRestrictions}}. It can be passed as a variable.

On the testing side, I think it would be good to:
* run your tests on {{COMPACT}} tables as well
* test with {{ORDER BY}} clauses for single and multi partition queries
* test with filtering on clustering columns and non-primary key columns / 
static columns

Problems tend to show up when several functionnalities are used together, so it 
is best to test the combinations which seems a bit risky. :-) 

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


[jira] [Commented] (CASSANDRA-11310) Allow filtering on clustering columns for queries without secondary indexes

2016-03-19 Thread Alex Petrov (JIRA)

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

Alex Petrov commented on CASSANDRA-11310:
-

I've tried to get it all sorted out and have handled most of the things by now, 
although some cases are harder to handle without larger changes. For example, 
within the {{StatementRestrictions}} we can't know whether there 
{{ClusteringColumnRestrictions}} would require filtering. One of the cases is 
multiple column slices, when clustering columns are given in the correct order. 
Without seeing actual restrictions (which are private to the 
{{PrimaryKeyRestrictionSet}}), we can't assert that there is more than one 
slice. 

I think it will be simpler to handle on top of your branch: 
https://github.com/blerer/cassandra/commits/11354-trunk, since there it's going 
to be possible to add logic related to the clustering columns within the 
clustering columns class. Do you think it's a good idea? 

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


[jira] [Commented] (CASSANDRA-11310) Allow filtering on clustering columns for queries without secondary indexes

2016-03-19 Thread Benjamin Lerer (JIRA)

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

Benjamin Lerer commented on CASSANDRA-11310:


A bit of explanation regarding multi-column restrictions:
if you have the following data:
||pk||clustering1||clustering2||
|1 | 1 | 1
|1 | 1 | 2
|1 | 1 | 3
|1 | 2 | 1
|1 | 2 | 2
|1 | 2 | 3

{{SELECT * FROM myTable WHERE pk = 1 AND (clustering1, clustering2) > (1, 2) 
AND (clustering1, clustering2) < (2, 3);}}
will return:

||pk||clustering1||clustering2||
|1 | 1 | 3
|1 | 2 | 1
|1 | 2 | 2

There are noway for the moment to translate that into filter expressions.

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


[jira] [Commented] (CASSANDRA-11310) Allow filtering on clustering columns for queries without secondary indexes

2016-03-15 Thread Benjamin Lerer (JIRA)

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

Benjamin Lerer commented on CASSANDRA-11310:


{quote}I'm still not sure if the handling of multi-columns is correct, since 
their SliceRestriction::addRowFilterTo is not permitted at the moment.{quote}

Sorry, I forgot to tell you that it cannot work.

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


[jira] [Commented] (CASSANDRA-11310) Allow filtering on clustering columns for queries without secondary indexes

2016-03-15 Thread Alex Petrov (JIRA)

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

Alex Petrov commented on CASSANDRA-11310:
-

That totally makes sense. I've added tests for the {{CONTAINS}} restrictions on 
the frozen collections (list and map).

Also, have addressed your other comments
  * renamed {{useFiltering}} to {{allowFiltering}}. I've sticked to the 
previously existing naming ({{useFiltering}} was already there, so I hesitated 
to change it at first)
  * renamed {{indexRestrictions}} to {{filteringRestrictions}} 
  * addressed {{StatementRestriction}} comments by checking whether we're doing 
filtering and adding {{clusteringColumnsRestrictions}} to 
{{filteringRestrictions}}, removed changes to {{getRowFilter}}

I have still pushed to the same branch: 
https://github.com/ifesdjeen/cassandra/commit/991c28b7b7ad8debbccfa9faed1b012f2388c231

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


[jira] [Commented] (CASSANDRA-11310) Allow filtering on clustering columns for queries without secondary indexes

2016-03-15 Thread Benjamin Lerer (JIRA)

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

Benjamin Lerer commented on CASSANDRA-11310:


{quote} so far the collection types aren't allowed to be a part of the primary 
key{quote}

They are if they are {{frozen}} :-).

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


[jira] [Commented] (CASSANDRA-11310) Allow filtering on clustering columns for queries without secondary indexes

2016-03-15 Thread Alex Petrov (JIRA)

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

Alex Petrov commented on CASSANDRA-11310:
-

I'm making the changes you've listed, hope to have them ready shortly.

About the {{CONTAINS}} restriction on the Clustering columns, I am most likely 
missing something, but at least so far the collection types aren't allowed to 
be a part of the primary key at all, even as a Clustering Column: {{Invalid 
collection type for PRIMARY KEY component b}} whenever {{b}} is a collection 
type.

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


[jira] [Commented] (CASSANDRA-11310) Allow filtering on clustering columns for queries without secondary indexes

2016-03-15 Thread Benjamin Lerer (JIRA)

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

Benjamin Lerer commented on CASSANDRA-11310:


Thanks for the initial patch. Overall, I think that you are going in the right 
direction.

While reviewing your patch I realised that some part of the code are really 
confusing. I opened CASSANDRA-11354 for improving the code of 
{{PrimaryKeyRestrictions}}.
In  {{PrimaryKeyRestrictions}} your changes looks good. Your changes in the 
constructor will also change the behavior 
for some secondary index requests. Queries like: {{SELECT * FROM myTable WHERE 
pk = 1 and clustering1 > 1 AND clustering2 > 1 AND x = 'test' ALLOW FILTERING}} 
used to be rejected and will now be accepted. It might be good if you could add 
some tests for that.

In my opinion, the {{useFiltering}} name is a bit confusing we should use 
{{allowFiltering}} instead as what the variable means is that the request had 
{{ALLOW FILTERING}} specified.

In {{StatementRestrictions}} some stuff looks wrong to me.
* In {{processClusteringColumnsRestrictions}} the fact that we set 
{{useSecondaryIndex}} to {{true}} if we allow filtering does not make sense. I 
am also not sure why we do it for views ([~thobbs] is there a good reason?).
* Instead of modifying {{getRowFilter}, I think that you should add 
{{clusteringColumnsRestrictions}} to {{indexRestrictions}} if filtering is 
allowed and some clustering columns restrictions require filtering.
* It might makes sense to rename {{indexRestrictions}} into 
{{filteringRestrictions}}.  

For {{CONTAINS}} restrictions I was thinking of {{CONTAINS}} restrictions on 
the Clustering columns. 

  


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


[jira] [Commented] (CASSANDRA-11310) Allow filtering on clustering columns for queries without secondary indexes

2016-03-09 Thread Benjamin Lerer (JIRA)

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

Benjamin Lerer commented on CASSANDRA-11310:


{quote}I'm not sure how fast I can pull it out, but I'll do my best.{quote}

Take your time. There is no pressure :-). 
It is an improvement which means that the next release for it is 3.6 anyway 
(May).
 

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


[jira] [Commented] (CASSANDRA-11310) Allow filtering on clustering columns for queries without secondary indexes

2016-03-09 Thread Alex Petrov (JIRA)

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

Alex Petrov commented on CASSANDRA-11310:
-

Thanks once again for the pointer! 

I somehow thought that it's possible to restrict everything by the bounds, 
which I thought of restricting on the both ends, but in the retrospect I 
understand that it was a rather bad idea.
I've implemented a "stupid" prototype that works for cases like {{SELECT * FROM 
%s WHERE b > 20 and c > 30 ALLOW FILTERING}}, so at least it's clear what to do 
now.

I'm not sure how fast I can pull it out, but I'll do my best.

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


[jira] [Commented] (CASSANDRA-11310) Allow filtering on clustering columns for queries without secondary indexes

2016-03-09 Thread Benjamin Lerer (JIRA)

[ 
https://issues.apache.org/jira/browse/CASSANDRA-11310?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=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)


[jira] [Commented] (CASSANDRA-11310) Allow filtering on clustering columns for queries without secondary indexes

2016-03-09 Thread Alex Petrov (JIRA)

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

Alex Petrov commented on CASSANDRA-11310:
-

I hope I'm not bugging you with questions too much. 
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`.
Thank you for your help.

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


[jira] [Commented] (CASSANDRA-11310) Allow filtering on clustering columns for queries without secondary indexes

2016-03-09 Thread Benjamin Lerer (JIRA)

[ 
https://issues.apache.org/jira/browse/CASSANDRA-11310?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=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)


[jira] [Commented] (CASSANDRA-11310) Allow filtering on clustering columns for queries without secondary indexes

2016-03-09 Thread Alex Petrov (JIRA)

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

Alex Petrov commented on CASSANDRA-11310:
-

[~blerer] I've moved forward a bit yesterday, as far as I understand problem 
consists of several parts:
  * when non-first clustering column is restricted (for example, in the b_mon 
in example table) with the slice restriction
  * when multiple clustering columns are restricted with slice restriction

So any combination of `b_mon > 'oct'`, `b_yr > '2015' AND b_mon > '06'` or 
`(b_yr, b_mon) > ('2015', '06')`, right? Since it seems that it's impossible at 
the moment to build a query where there's more than a single non-EQ 
restrictions.

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


[jira] [Commented] (CASSANDRA-11310) Allow filtering on clustering columns for queries without secondary indexes

2016-03-07 Thread Benjamin Lerer (JIRA)

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

Benjamin Lerer commented on CASSANDRA-11310:


:-)

A couple of hints:

I believe that the 2 main problems are the validation in 
{{StatementRestrictions::processClusteringColumnsRestrictions}} and the way the 
{{Clustering}} and {{Slice.Bound}} sets are build in 
{{PrimaryKeyRestrictionSet::valuesAsClustering}} and 
{{PrimaryKeyRestrictionSet::boundsAsClustering}} methods.

The unit test for filtering on non-primary key columns are located in 
{{SelectTest}} and the DTests for testing filtering with paging are in 
{{paging.py}}.

This change should also makes queries like: {{SELECT * FROM emp_table2 WHERE 
(b_yr, b_mon) > ('2015', 'oct') AND b_day ='01' ALLOW FILTERING}} fully valid. 
It will be great if you could also provide some test for that kind of query.

If you need some help do not hesitate to ping me. 

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


[jira] [Commented] (CASSANDRA-11310) Allow filtering on clustering columns for queries without secondary indexes

2016-03-07 Thread Alex Petrov (JIRA)

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

Alex Petrov commented on CASSANDRA-11310:
-

[~blerer] absolutely! Will be happy to. I'll check it out in more details 
tonight. 

> 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: Benjamin Lerer
> 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)


[jira] [Commented] (CASSANDRA-11310) Allow filtering on clustering columns for queries without secondary indexes

2016-03-07 Thread Benjamin Lerer (JIRA)

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

Benjamin Lerer commented on CASSANDRA-11310:


[~ifesdjeen] as you had started to look into the filtering for CASSANDRA-10715, 
would you be interested in working on this issue? 

> 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: Benjamin Lerer
> 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)