[ 
https://issues.apache.org/jira/browse/CASSJAVA-3?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17909466#comment-17909466
 ] 

Lukasz Antoniak commented on CASSJAVA-3:
----------------------------------------

Thanks for pointing it out. Do you mind submitting a PR to get all the credits?

> Select Query Builder puts 'Limit' and 'Per Partition Limit' in the wrong order
> ------------------------------------------------------------------------------
>
>                 Key: CASSJAVA-3
>                 URL: https://issues.apache.org/jira/browse/CASSJAVA-3
>             Project: Apache Cassandra Java driver
>          Issue Type: Bug
>            Reporter: David Stringer
>            Priority: Normal
>         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:
>  
> First discovered the issue in version 4.18.1 - still exists in 4.18.2-SNAPSHOT
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org
For additional commands, e-mail: commits-h...@cassandra.apache.org

Reply via email to