doanduyhai / Achilles

An advanced Java Object Mapper/Query DSL generator for Cassandra
http://achilles.archinnov.info
Apache License 2.0
241 stars 92 forks source link

Table_Select.W always returns default cluster (1) #352

Closed RaAleks closed 5 years ago

RaAleks commented 5 years ago

Hi @doanduyhai, i have a table such as below. So i want that Achilles returns me table with cluster2 in descending order. But Table_Select.W always returns W_Cluster1, that's why i can't see ability to set descending order for my second cluster. Also below code for test manager what i want to have.

@Table(table = "test_table") public class TestTable {

@PartitionKey
private String partition;

@ClusteringColumn
private String cluster1;

@ClusteringColumn(value = 2, asc = false)
private Date cluster2;

}

testTable_manager .dsl() .select() .allColumns_FromBaseTable() .where() .partition() .Eq("test") .orderByCluster2Descending() .groupBy() .cluster1_cluster2() .getList();

doanduyhai commented 5 years ago

It is not an issue. By design Cassandra only allow you to use ORDER BY on the 1st clustering column in your query

RaAleks commented 5 years ago

Oh, thanks for quick response, just tried query to cassandra in console, and you are absolutely right! Many thanks!

RaAleks commented 5 years ago

But if i write this request, cassandra allow me to make second clustering column in desc order. SELECT * FROM test WHERE partition= 'test' ORDER BY cluster1 DESC, cluster2 DESC;

But achilles not allows.

doanduyhai commented 5 years ago

Which version of Cassandra are you using ?

doanduyhai commented 5 years ago

Also please provide CREATE TABLE script

RaAleks commented 5 years ago

Here is create table CREATE TABLE test ( partition text, cluster1 text, cluster2 text, PRIMARY KEY (partition , cluster1 , cluster2 ) ); Version: [cqlsh 5.0.1 | Cassandra 3.11.3 | CQL spec 3.4.4 | Native protocol v4]