cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sylvain Lebresne (JIRA)" <>
Subject [jira] [Resolved] (CASSANDRA-8567) Functions like length() and trim() on cqlsh table fields
Date Tue, 06 Jan 2015 08:10:34 GMT


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:
>             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

View raw message