Given the following legacy table:
create table "MyKeyspace"."CkeyTest" ( accountid bigint, descbigint1 bigint, ascbigint2 bigint, ascstring1 ascii, value text, PRIMARY KEY ((accountid), descbigint1, ascbigint2, ascstring1)) WITH CLUSTERING ORDER BY (descbigint1 DESC, ascbigint2 ASC, ascstring1 ASC) AND COMPACT STORAGE;
And 15 rows inserted such that:
SELECT accountid, descbigint1, ascbigint2, ascstring1, value FROM "MyKeyspace"."CkeyTest" WHERE accountid=111;
returns:
accountid, descbigint1, ascbigint2, ascstring1, value =================================================== 111,262,325,cherry,red 111,262,333,cherry,red 111,252,324,kiwi,green 111,252,343,kiwi,green 111,242,323,banana,yellow 111,242,353,banana,yellow *** 111,232,322,apple,green 111,232,363,apple,green 111,222,333,apple,green 111,222,333,banana,yellow 111,222,333,cherry,red 111,222,333,kiwi,green 111,222,343,kiwi,green 111,222,353,banana,yellow 111,222,363,apple,green
What is the CQL that will give me rows starting with row *** and the ones following, i.e.:
accountid, descbigint1, ascbigint2, ascstring1, value ==================================================== 111,242,353,banana,yellow *** 111,232,322,apple,green 111,232,363,apple,green 111,222,333,apple,green 111,222,333,banana,yellow 111,222,333,cherry,red 111,222,333,kiwi,green 111,222,343,kiwi,green 111,222,353,banana,yellow 111,222,363,apple,green
I think the first clustering column being DESC is messing me up. The closest I've come is the following query but it returns rows starting with clustering column 242:
SELECT accountid, descbigint1, ascbigint2, ascstring1, value FROM "MyKeyspace"."CkeyTest" WHERE accountid = 111 AND (descbigint1) <= (242) AND (descbigint1,ascbigint2,ascstring1) >= (1,353,'banana'); accountid, descbigint1, ascbigint2, ascstring1, value ==================================================== 111,242,323,banana,yellow 111,242,353,banana,yellow *** 111,232,322,apple,green 111,232,363,apple,green 111,222,333,apple,green 111,222,333,banana,yellow 111,222,333,cherry,red 111,222,333,kiwi,green 111,222,343,kiwi,green 111,222,353,banana,yellow 111,222,363,apple,green
Script to create table and insert data CkeyTest.txt
If I insert the same data with all clustering columns in ASC order, I seem to have no issue querying with any of the rows as a starting row.
Note I'm able to do this kind of query with Hector. I'm trying move our REST API from Hector to CQL and our paging relies on a "nextkey" comprised of serialized clustering columns (Composite column name for those familiar with Hector) as a starting point. I'm trying to maintain this paging if I can as we have several tables with "mixed order" clustering column like above and we'll be in a mixed Hector/CQL mode for awhile as we roll this out.
Lastly, I really want to avoid filtering client side as our tables may have thousands of rows with the same value in the first clustering column. Any help is appreciated!