You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cassandra.apache.org by Sorin Manolache <so...@gmail.com> on 2013/04/11 17:19:08 UTC

is the select result grouped by the value of the partition key?

Hello,

Let us consider that we have a table t created as follows:

create table t(k1 vachar, k2 varchar, value varchar, primary key (k1, k2));

Its contents is

a m x
a n y
z 0 9
z 1 8

and I perform a

select * from p where k1 in ('a', 'z');

Is it guaranteed that the rows are grouped by the value of the partition 
key? That is, is it guaranteed that I'll get

a m x
a n y
z 0 9
z 1 8

or

a n y
a m x
z 1 8
z 0 9

or even

z 0 9
z 1 8
a n y
a m x

but NEVER

a m x
z 0 9
a n y
z 1 8


Thank you,
Sorin

Re: is the select result grouped by the value of the partition key?

Posted by aaron morton <aa...@thelastpickle.com>.
> 
>>> Is it guaranteed that the rows are grouped by the value of the
>>> partition key? That is, is it guaranteed that I'll get
yes.


-----------------
Aaron Morton
Freelance Cassandra Consultant
New Zealand

@aaronmorton
http://www.thelastpickle.com

On 12/04/2013, at 7:24 PM, Sorin Manolache <so...@gmail.com> wrote:

> On 2013-04-11 22:10, aaron morton wrote:
>>> Is it guaranteed that the rows are grouped by the value of the
>>> partition key? That is, is it guaranteed that I'll get
>> Your primary key (k1, k2) is considered in type parts (partition_key ,
>> grouping_columns). In your case the primary_key is key and the grouping
>> column in k2. Columns are ordered by the grouping columns, k2.
>> 
>> See http://thelastpickle.com/2013/01/11/primary-keys-in-cql/
> 
> Thank you for the answer.
> 
> However my question was about the _grouping_ (not ordering) of _rows_ (not columns).
> 
> Sorin
> 
>> 
>> Cheers
>> 
>> -----------------
>> Aaron Morton
>> Freelance Cassandra Consultant
>> New Zealand
>> 
>> @aaronmorton
>> http://www.thelastpickle.com
>> 
>> On 12/04/2013, at 3:19 AM, Sorin Manolache <sorinm@gmail.com
>> <ma...@gmail.com>> wrote:
>> 
>>> Hello,
>>> 
>>> Let us consider that we have a table t created as follows:
>>> 
>>> create table t(k1 vachar, k2 varchar, value varchar, primary key (k1,
>>> k2));
>>> 
>>> Its contents is
>>> 
>>> a m x
>>> a n y
>>> z 0 9
>>> z 1 8
>>> 
>>> and I perform a
>>> 
>>> select * from p where k1 in ('a', 'z');
>>> 
>>> Is it guaranteed that the rows are grouped by the value of the
>>> partition key? That is, is it guaranteed that I'll get
>>> 
>>> a m x
>>> a n y
>>> z 0 9
>>> z 1 8
>>> 
>>> or
>>> 
>>> a n y
>>> a m x
>>> z 1 8
>>> z 0 9
>>> 
>>> or even
>>> 
>>> z 0 9
>>> z 1 8
>>> a n y
>>> a m x
>>> 
>>> but NEVER
>>> 
>>> a m x
>>> z 0 9
>>> a n y
>>> z 1 8
>>> 
>>> 
>>> Thank you,
>>> Sorin
>> 
> 


Re: is the select result grouped by the value of the partition key?

Posted by Sorin Manolache <so...@gmail.com>.
On 2013-04-11 22:10, aaron morton wrote:
>> Is it guaranteed that the rows are grouped by the value of the
>> partition key? That is, is it guaranteed that I'll get
> Your primary key (k1, k2) is considered in type parts (partition_key ,
> grouping_columns). In your case the primary_key is key and the grouping
> column in k2. Columns are ordered by the grouping columns, k2.
>
> See http://thelastpickle.com/2013/01/11/primary-keys-in-cql/

Thank you for the answer.

However my question was about the _grouping_ (not ordering) of _rows_ 
(not columns).

Sorin

>
> Cheers
>
> -----------------
> Aaron Morton
> Freelance Cassandra Consultant
> New Zealand
>
> @aaronmorton
> http://www.thelastpickle.com
>
> On 12/04/2013, at 3:19 AM, Sorin Manolache <sorinm@gmail.com
> <ma...@gmail.com>> wrote:
>
>> Hello,
>>
>> Let us consider that we have a table t created as follows:
>>
>> create table t(k1 vachar, k2 varchar, value varchar, primary key (k1,
>> k2));
>>
>> Its contents is
>>
>> a m x
>> a n y
>> z 0 9
>> z 1 8
>>
>> and I perform a
>>
>> select * from p where k1 in ('a', 'z');
>>
>> Is it guaranteed that the rows are grouped by the value of the
>> partition key? That is, is it guaranteed that I'll get
>>
>> a m x
>> a n y
>> z 0 9
>> z 1 8
>>
>> or
>>
>> a n y
>> a m x
>> z 1 8
>> z 0 9
>>
>> or even
>>
>> z 0 9
>> z 1 8
>> a n y
>> a m x
>>
>> but NEVER
>>
>> a m x
>> z 0 9
>> a n y
>> z 1 8
>>
>>
>> Thank you,
>> Sorin
>


Re: is the select result grouped by the value of the partition key?

Posted by aaron morton <aa...@thelastpickle.com>.
> Is it guaranteed that the rows are grouped by the value of the partition key? That is, is it guaranteed that I'll get
Your primary key (k1, k2) is considered in type parts (partition_key , grouping_columns). In your case the primary_key is key and the grouping column in k2. Columns are ordered by the grouping columns, k2. 

See http://thelastpickle.com/2013/01/11/primary-keys-in-cql/

Cheers

-----------------
Aaron Morton
Freelance Cassandra Consultant
New Zealand

@aaronmorton
http://www.thelastpickle.com

On 12/04/2013, at 3:19 AM, Sorin Manolache <so...@gmail.com> wrote:

> Hello,
> 
> Let us consider that we have a table t created as follows:
> 
> create table t(k1 vachar, k2 varchar, value varchar, primary key (k1, k2));
> 
> Its contents is
> 
> a m x
> a n y
> z 0 9
> z 1 8
> 
> and I perform a
> 
> select * from p where k1 in ('a', 'z');
> 
> Is it guaranteed that the rows are grouped by the value of the partition key? That is, is it guaranteed that I'll get
> 
> a m x
> a n y
> z 0 9
> z 1 8
> 
> or
> 
> a n y
> a m x
> z 1 8
> z 0 9
> 
> or even
> 
> z 0 9
> z 1 8
> a n y
> a m x
> 
> but NEVER
> 
> a m x
> z 0 9
> a n y
> z 1 8
> 
> 
> Thank you,
> Sorin