Details
-
Bug
-
Status: Resolved
-
Normal
-
Resolution: Fixed
-
None
-
None
Description
Using the QueryBuilder to build a statement that uses both Partition Limit and Limit results in an invalid query. The order of the literals in the generated query places Limit before Partition Limit, which is the inverse of what is should be.
Sample of the invalid query that was generated by the Query Builder and executed in CqlSh:
cassandra@cqlsh:project> select "token"(organization_id,environment_id,feature),feature,organization_id,environment_id,enabled from features WHERE token(organization_id,environment_id,feature)>=-9223372036854775808 LIMIT 5 PER PARTITION LIMIT 1; SyntaxException: line 1:199 mismatched input 'PER' expecting EOF (...,feature)>=-9223372036854775808 LIMIT 5 [PER]...)
This is what the query should have been:
cassandra@cqlsh:project> select "token"(organization_id,environment_id,feature),feature,organization_id,environment_id,enabled from features WHERE token(organization_id,environment_id,feature)>=-9223372036854775808 PER PARTITION LIMIT 1 LIMIT 1;
system.token(organization_id, environment_id, feature) | feature | organization_id | environment_id | enabled
--------------------------------------------------------+---------+-----------------+----------------+---------(0 rows)
As documented for Select - limit should follow per partition limit.
Syntax:
<select-stmt> ::= SELECT ( JSON )? <select-clause>
FROM <tablename>
( WHERE <where-clause> )?
( GROUP BY <group-by>)?
( ORDER BY <order-by> )?
( PER PARTITION LIMIT <integer> )?
( LIMIT <integer> )?
( ALLOW FILTERING )?
It looks to be a very minor fix in the code - attached patch and test to verify the issue:
First discovered the issue in version 4.18.1 - still exists in 4.18.2-SNAPSHOT
Attachments
Attachments
Issue Links
- links to