David Stringer created CASSANDRA-19982:
------------------------------------------
Summary: Select Query Builder puts 'Limit' and 'Per Partition
Limit' in the wrong order
Key: CASSANDRA-19982
URL: https://issues.apache.org/jira/browse/CASSANDRA-19982
Project: Cassandra
Issue Type: Bug
Components: Client/java-driver
Reporter: David Stringer
Attachments: queryBuilder.patch
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:
{code:java}
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]...){code}
{{This is what the query should have been:}}
{code:java}
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)
{code}
{{As documented for
[Select|file:///opt/cassandra-versions/apache-cassandra-3.11.9/doc/cql3/CQL.html#selectStmt]
- *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:
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]