You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cassandra.apache.org by "techpyaasa ." <te...@gmail.com> on 2017/07/03 20:14:55 UTC

UDF for sorting

Hi all,

I have a table like

CREATE TABLE ks.cf ( pk1 bigint, cc1 bigint, disp_name text , stat_obj
text, status int, PRIMARY KEY (pk1, cc1)) WITH CLUSTERING ORDER BY (cc1 ASC)

CREATE INDEX idx1 on ks.cf(status);

I want to have a queries like
*select * from ks.cf <http://ks.cf> where pk1=123 and cc1=345;*

and
*select * from ks.cf <http://ks.cf> where pk1=123 and status=1;*
In this case , I want rows to be sorted based on 'disp_name' (asc/desc) .

Can I achieve the same using UDF or anything else ?? (Sorry If my
understanding about UDF is wrong).

Thanks in advance
TechPyaasa

Re: UDF for sorting

Posted by Eduardo Alonso <ed...@stratio.com>.
I have read HowToContribute
<https://wiki.apache.org/cassandra/HowToContribute> and created the ticket
CASSANDRA-13682 <https://issues.apache.org/jira/browse/CASSANDRA-13682>
with PR and path available flag.


Eduardo Alonso
Vía de las dos Castillas, 33, Ática 4, 3ª Planta
28224 Pozuelo de Alarcón, Madrid
Tel: +34 91 828 6473 // www.stratio.com // *@stratiobd
<https://twitter.com/StratioBD>*

2017-07-06 14:43 GMT+02:00 Eduardo Alonso <ed...@stratio.com>:

> Hi Jeff:
>
> Do you mean something like this
> <https://github.com/apache/cassandra/pull/128>?
>
> This is so basic(with no code change ) that i I have skipped the JIRA
> ticket creation
>
> Could you please review?
> Thank you
>
> Eduardo Alonso
> Vía de las dos Castillas, 33, Ática 4, 3ª Planta
> 28224 Pozuelo de Alarcón, Madrid
> Tel: +34 91 828 6473 // www.stratio.com // *@stratiobd
> <https://twitter.com/StratioBD>*
>
> 2017-07-05 23:49 GMT+02:00 Jeff Jirsa <jj...@apache.org>:
>
>>
>>
>> On 2017-07-03 16:19 (-0700), Justin Cameron <ju...@instaclustr.com>
>> wrote:
>> > While you can't do this with Cassandra, you can get the functionality
>> you
>> > want with the cassandra-lucene-plugin (
>> > https://github.com/Stratio/cassandra-lucene-index/blob/branc
>> h-3.0.10/doc/documentation.rst#searching
>> > ).
>> >
>> > Keep in mind that as with any secondary index there are
>> performance-related
>> > limitations:
>> > https://github.com/Stratio/cassandra-lucene-index/blob/branc
>> h-3.0.10/doc/documentation.rst#performance-tips
>>
>>
>> We just added a "Plugins" section to the docs (
>> https://github.com/apache/cassandra/blob/trunk/doc/source/
>> plugins/index.rst )  - it would be nice if someone would add the
>> Cassandra-Lucene-Index plugin there.
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@cassandra.apache.org
>> For additional commands, e-mail: user-help@cassandra.apache.org
>>
>>
>

Re: UDF for sorting

Posted by Eduardo Alonso <ed...@stratio.com>.
Hi Jeff:

Do you mean something like this
<https://github.com/apache/cassandra/pull/128>?

This is so basic(with no code change ) that i I have skipped the JIRA
ticket creation

Could you please review?
Thank you

Eduardo Alonso
Vía de las dos Castillas, 33, Ática 4, 3ª Planta
28224 Pozuelo de Alarcón, Madrid
Tel: +34 91 828 6473 // www.stratio.com // *@stratiobd
<https://twitter.com/StratioBD>*

2017-07-05 23:49 GMT+02:00 Jeff Jirsa <jj...@apache.org>:

>
>
> On 2017-07-03 16:19 (-0700), Justin Cameron <ju...@instaclustr.com>
> wrote:
> > While you can't do this with Cassandra, you can get the functionality you
> > want with the cassandra-lucene-plugin (
> > https://github.com/Stratio/cassandra-lucene-index/blob/
> branch-3.0.10/doc/documentation.rst#searching
> > ).
> >
> > Keep in mind that as with any secondary index there are
> performance-related
> > limitations:
> > https://github.com/Stratio/cassandra-lucene-index/blob/
> branch-3.0.10/doc/documentation.rst#performance-tips
>
>
> We just added a "Plugins" section to the docs ( https://github.com/apache/
> cassandra/blob/trunk/doc/source/plugins/index.rst )  - it would be nice
> if someone would add the Cassandra-Lucene-Index plugin there.
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@cassandra.apache.org
> For additional commands, e-mail: user-help@cassandra.apache.org
>
>

Re: UDF for sorting

Posted by Jeff Jirsa <jj...@apache.org>.

On 2017-07-03 16:19 (-0700), Justin Cameron <ju...@instaclustr.com> wrote: 
> While you can't do this with Cassandra, you can get the functionality you
> want with the cassandra-lucene-plugin (
> https://github.com/Stratio/cassandra-lucene-index/blob/branch-3.0.10/doc/documentation.rst#searching
> ).
> 
> Keep in mind that as with any secondary index there are performance-related
> limitations:
> https://github.com/Stratio/cassandra-lucene-index/blob/branch-3.0.10/doc/documentation.rst#performance-tips


We just added a "Plugins" section to the docs ( https://github.com/apache/cassandra/blob/trunk/doc/source/plugins/index.rst )  - it would be nice if someone would add the Cassandra-Lucene-Index plugin there.




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


Re: UDF for sorting

Posted by Justin Cameron <ju...@instaclustr.com>.
Yes, it does - you'll just have to build for the 2.1.17 branch. You also
will have to use their alternative query syntax:
https://github.com/Stratio/cassandra-lucene-index/blob/branch-3.0.10/doc/documentation.rst#alternative-syntaxes


On Tue, 4 Jul 2017 at 17:27 techpyaasa . <te...@gmail.com> wrote:

> Hi Justin,
>
> Thanks for the reply.
> We are using c*-2.1.17 , does lucene plugin works with this version??
>
> On Tue, Jul 4, 2017 at 4:49 AM, Justin Cameron <ju...@instaclustr.com>
> wrote:
>
>> While you can't do this with Cassandra, you can get the functionality you
>> want with the cassandra-lucene-plugin (
>> https://github.com/Stratio/cassandra-lucene-index/blob/branch-3.0.10/doc/documentation.rst#searching
>> ).
>>
>> Keep in mind that as with any secondary index there are
>> performance-related limitations:
>> https://github.com/Stratio/cassandra-lucene-index/blob/branch-3.0.10/doc/documentation.rst#performance-tips
>>
>>
>> On Tue, 4 Jul 2017 at 07:17 DuyHai Doan <do...@gmail.com> wrote:
>>
>>> Plain answer is no you can't
>>>
>>> The reason is that UDF only transform column values on each row but does
>>> not have the ability to modify rows ordering
>>>
>>> On Mon, Jul 3, 2017 at 10:14 PM, techpyaasa . <te...@gmail.com>
>>> wrote:
>>>
>>>> Hi all,
>>>>
>>>> I have a table like
>>>>
>>>> CREATE TABLE ks.cf ( pk1 bigint, cc1 bigint, disp_name text , stat_obj
>>>> text, status int, PRIMARY KEY (pk1, cc1)) WITH CLUSTERING ORDER BY (cc1 ASC)
>>>>
>>>> CREATE INDEX idx1 on ks.cf(status);
>>>>
>>>> I want to have a queries like
>>>> *select * from ks.cf <http://ks.cf> where pk1=123 and cc1=345;*
>>>>
>>>> and
>>>> *select * from ks.cf <http://ks.cf> where pk1=123 and status=1;*
>>>> In this case , I want rows to be sorted based on 'disp_name' (asc/desc)
>>>> .
>>>>
>>>> Can I achieve the same using UDF or anything else ?? (Sorry If my
>>>> understanding about UDF is wrong).
>>>>
>>>> Thanks in advance
>>>> TechPyaasa
>>>>
>>>
>>> --
>>
>>
>> *Justin Cameron*Senior Software Engineer
>>
>>
>> <https://www.instaclustr.com/>
>>
>>
>> This email has been sent on behalf of Instaclustr Pty. Limited
>> (Australia) and Instaclustr Inc (USA).
>>
>> This email and any attachments may contain confidential and legally
>> privileged information.  If you are not the intended recipient, do not copy
>> or disclose its content, but please reply to this email immediately and
>> highlight the error to the sender and then immediately delete the message.
>>
>
> --


*Justin Cameron*Senior Software Engineer


<https://www.instaclustr.com/>


This email has been sent on behalf of Instaclustr Pty. Limited (Australia)
and Instaclustr Inc (USA).

This email and any attachments may contain confidential and legally
privileged information.  If you are not the intended recipient, do not copy
or disclose its content, but please reply to this email immediately and
highlight the error to the sender and then immediately delete the message.

Re: UDF for sorting

Posted by "techpyaasa ." <te...@gmail.com>.
Hi Justin,

Thanks for the reply.
We are using c*-2.1.17 , does lucene plugin works with this version??

On Tue, Jul 4, 2017 at 4:49 AM, Justin Cameron <ju...@instaclustr.com>
wrote:

> While you can't do this with Cassandra, you can get the functionality you
> want with the cassandra-lucene-plugin (https://github.com/Stratio/
> cassandra-lucene-index/blob/branch-3.0.10/doc/documentation.rst#searching
> ).
>
> Keep in mind that as with any secondary index there are
> performance-related limitations: https://github.
> com/Stratio/cassandra-lucene-index/blob/branch-3.0.10/doc/
> documentation.rst#performance-tips
>
> On Tue, 4 Jul 2017 at 07:17 DuyHai Doan <do...@gmail.com> wrote:
>
>> Plain answer is no you can't
>>
>> The reason is that UDF only transform column values on each row but does
>> not have the ability to modify rows ordering
>>
>> On Mon, Jul 3, 2017 at 10:14 PM, techpyaasa . <te...@gmail.com>
>> wrote:
>>
>>> Hi all,
>>>
>>> I have a table like
>>>
>>> CREATE TABLE ks.cf ( pk1 bigint, cc1 bigint, disp_name text , stat_obj
>>> text, status int, PRIMARY KEY (pk1, cc1)) WITH CLUSTERING ORDER BY (cc1 ASC)
>>>
>>> CREATE INDEX idx1 on ks.cf(status);
>>>
>>> I want to have a queries like
>>> *select * from ks.cf <http://ks.cf> where pk1=123 and cc1=345;*
>>>
>>> and
>>> *select * from ks.cf <http://ks.cf> where pk1=123 and status=1;*
>>> In this case , I want rows to be sorted based on 'disp_name' (asc/desc) .
>>>
>>> Can I achieve the same using UDF or anything else ?? (Sorry If my
>>> understanding about UDF is wrong).
>>>
>>> Thanks in advance
>>> TechPyaasa
>>>
>>
>> --
>
>
> *Justin Cameron*Senior Software Engineer
>
>
> <https://www.instaclustr.com/>
>
>
> This email has been sent on behalf of Instaclustr Pty. Limited (Australia)
> and Instaclustr Inc (USA).
>
> This email and any attachments may contain confidential and legally
> privileged information.  If you are not the intended recipient, do not copy
> or disclose its content, but please reply to this email immediately and
> highlight the error to the sender and then immediately delete the message.
>

Re: UDF for sorting

Posted by Justin Cameron <ju...@instaclustr.com>.
While you can't do this with Cassandra, you can get the functionality you
want with the cassandra-lucene-plugin (
https://github.com/Stratio/cassandra-lucene-index/blob/branch-3.0.10/doc/documentation.rst#searching
).

Keep in mind that as with any secondary index there are performance-related
limitations:
https://github.com/Stratio/cassandra-lucene-index/blob/branch-3.0.10/doc/documentation.rst#performance-tips


On Tue, 4 Jul 2017 at 07:17 DuyHai Doan <do...@gmail.com> wrote:

> Plain answer is no you can't
>
> The reason is that UDF only transform column values on each row but does
> not have the ability to modify rows ordering
>
> On Mon, Jul 3, 2017 at 10:14 PM, techpyaasa . <te...@gmail.com>
> wrote:
>
>> Hi all,
>>
>> I have a table like
>>
>> CREATE TABLE ks.cf ( pk1 bigint, cc1 bigint, disp_name text , stat_obj
>> text, status int, PRIMARY KEY (pk1, cc1)) WITH CLUSTERING ORDER BY (cc1 ASC)
>>
>> CREATE INDEX idx1 on ks.cf(status);
>>
>> I want to have a queries like
>> *select * from ks.cf <http://ks.cf> where pk1=123 and cc1=345;*
>>
>> and
>> *select * from ks.cf <http://ks.cf> where pk1=123 and status=1;*
>> In this case , I want rows to be sorted based on 'disp_name' (asc/desc) .
>>
>> Can I achieve the same using UDF or anything else ?? (Sorry If my
>> understanding about UDF is wrong).
>>
>> Thanks in advance
>> TechPyaasa
>>
>
> --


*Justin Cameron*Senior Software Engineer


<https://www.instaclustr.com/>


This email has been sent on behalf of Instaclustr Pty. Limited (Australia)
and Instaclustr Inc (USA).

This email and any attachments may contain confidential and legally
privileged information.  If you are not the intended recipient, do not copy
or disclose its content, but please reply to this email immediately and
highlight the error to the sender and then immediately delete the message.

Re: UDF for sorting

Posted by DuyHai Doan <do...@gmail.com>.
Plain answer is no you can't

The reason is that UDF only transform column values on each row but does
not have the ability to modify rows ordering

On Mon, Jul 3, 2017 at 10:14 PM, techpyaasa . <te...@gmail.com> wrote:

> Hi all,
>
> I have a table like
>
> CREATE TABLE ks.cf ( pk1 bigint, cc1 bigint, disp_name text , stat_obj
> text, status int, PRIMARY KEY (pk1, cc1)) WITH CLUSTERING ORDER BY (cc1 ASC)
>
> CREATE INDEX idx1 on ks.cf(status);
>
> I want to have a queries like
> *select * from ks.cf <http://ks.cf> where pk1=123 and cc1=345;*
>
> and
> *select * from ks.cf <http://ks.cf> where pk1=123 and status=1;*
> In this case , I want rows to be sorted based on 'disp_name' (asc/desc) .
>
> Can I achieve the same using UDF or anything else ?? (Sorry If my
> understanding about UDF is wrong).
>
> Thanks in advance
> TechPyaasa
>