You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by "Sylvain Lebresne (JIRA)" <ji...@apache.org> on 2015/01/06 09:10:34 UTC

[jira] [Resolved] (CASSANDRA-8567) Functions like length() and trim() on cqlsh table fields

     [ https://issues.apache.org/jira/browse/CASSANDRA-8567?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Sylvain Lebresne resolved CASSANDRA-8567.
-----------------------------------------
    Resolution: Won't Fix

We might add some {{length}} and {{trim}} method at some point, though even if we don't, UDF in 3.0 will allow you to define them. But what you're really asking here is to be able to use functions in {{ORDER BY}}, and that is not going to happen. The reason is that we have no better strategy server side than to read everything and sort it in memory afterwards before returning to the client. Which 1) is no faster than letting you the client do the sorting client side and 2) doesn't work with paging at all and thus makes it likely to OOM as soon as the amount of data to order is not small.

For those reason, we prefer letting clients do the sorting themselves post-query if they wants to (but we understand that for cqlsh it's not as nice as you'd like. Though if you really need quick and dirty post-query sorting, piping the output of cqlsh into sort (the unix utility) isn't terribly hard). Alternatively, if you need results in that sort order often, you should store the data in a table whose clustering is {{length(trim(field)}}.

> Functions like length() and trim() on cqlsh table fields
> --------------------------------------------------------
>
>                 Key: CASSANDRA-8567
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-8567
>             Project: Cassandra
>          Issue Type: Wish
>          Components: Core
>            Reporter: Rekha Joshi
>
> It would be nice to be able to order by length of field values.
> A function like length(field) and trim(field) on cqlsh
> To enable do something like say - select * from  <table> where <field1>=<value> order by length(trim(<field2>)) desc;
> Thanks.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)