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

Chris mildebrandt commented on CASSANDRA-14376:
-----------------------------------------------

Sample for reproduction:

{{create table if not exists samples (name text, partition int, sample int, 
city text, state text, count counter, primary key ((name, partition), sample, 
city, state)) with clustering order by (sample desc);}}

{{update samples set count=count+1 where name='bob' and partition=1 and 
sample=1 and city='Denver' and state='CO';}}
{{update samples set count=count+1 where name='bob' and partition=1 and 
sample=2 and city='Denver' and state='CO';}}
{{update samples set count=count+1 where name='bob' and partition=1 and 
sample=3 and city='Denver' and state='CO';}}
{{update samples set count=count+1 where name='bob' and partition=1 and 
sample=3 and city='Denver' and state='CO';}}
{{update samples set count=count+1 where name='bob' and partition=1 and 
sample=1 and city='Austin' and state='TX';}}
{{update samples set count=count+1 where name='bob' and partition=1 and 
sample=1 and city='Austin' and state='TX';}}
{{update samples set count=count+1 where name='bob' and partition=1 and 
sample=2 and city='Austin' and state='TX';}}
{{update samples set count=count+1 where name='bob' and partition=1 and 
sample=2 and city='Austin' and state='TX';}}
{{update samples set count=count+1 where name='bob' and partition=1 and 
sample=2 and city='Austin' and state='TX';}}

{{select city, state, sum(count) from samples where name='bob' and partition=1 
and sample>=1 and sample<=3 group by city, state;}}
{{select city, state, sum(count) from samples where name='bob' and partition=1 
and sample=1 group by city, state;}}

> Limiting a clustering column with a range not allowed when using "group by"
> ---------------------------------------------------------------------------
>
>                 Key: CASSANDRA-14376
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-14376
>             Project: Cassandra
>          Issue Type: Bug
>          Components: CQL
>         Environment: Cassandra 3.11.1
>            Reporter: Chris mildebrandt
>            Priority: Major
>
> I’m trying to use a range to limit a clustering column while at the same time 
> using `group by` and running into issues. Here’s a sample table:
> {{create table if not exists samples (name text, partition int, sample int, 
> city text, state text, count counter, primary key ((name, partition), sample, 
> city, state)) with clustering order by (sample desc);}}
> When I filter `sample` by a range, I get an error:
> {{select city, state, sum(count) from samples where name='bob' and 
> partition=1 and sample>=1 and sample<=3 group by city, state;}}
>  {{{color:#ff0000}InvalidRequest: Error from server: code=2200 [Invalid 
> query] message="Group by currently only support groups of columns following 
> their declared order in the PRIMARY KEY"{color}}}
> However, it allows the query when I change from a range to an equals:
> {{select city, state, sum(count) from samples where name='bob' and 
> partition=1 and sample=1 group by city, state;}}
> {{city | state | system.sum(count)}}
> {{--------++--------------------------}}
> {{ Austin | TX | 2}}
> {{ Denver | CO | 1}}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org
For additional commands, e-mail: commits-h...@cassandra.apache.org

Reply via email to