Re: "Group by" while limiting a clustering column with a range

2018-04-10 Thread eyeofthefrog
I've opened the following issue: 
https://issues.apache.org/jira/browse/CASSANDRA-14376

On 2018/04/10 23:12:31, Chris Mildebrandt  wrote: 
> Hey all. 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;
> 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"
> 
> 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
> 
> Does this sound like a bug, or is it expected? Thanks.
> 

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



"Group by" while limiting a clustering column with a range

2018-04-10 Thread Chris Mildebrandt
Hey all. 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;
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"

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

Does this sound like a bug, or is it expected? Thanks.