Question

Im finding that my CQL3 order by statements are returning strange results, where any strings starting with uppercase letters are ordered first, and then the lowercase strings are ordered second.

Heres an example table:

CREATE TABLE tester 
(rowkey text, colname text, colvalue text, primary key (rowkey, colname)) 
WITH COMPACT STORAGE;

If I populate it with some test data and run the following query this is what I get:

Query:

SELECT * FROM tester WHERE rowkey = 'test' ORDER BY colname ASC

Results:

rowkey | colname | colvalue
-------+---------+---------
test   | ABC     | blah
test   | Abc     | blah
test   | BBC     | blah
test   | abc     | blah
test   | bbC     | blah
test   | bbc     | blah

I cant see how that would be expected behavior. Does anyone know why its ordering it like that and how to achieve a more sensible order?

Was it helpful?

Solution

Your columns are being sorted in lexicographical order, in which upper case characters have precedence over lower case.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top