[ https://issues.apache.org/jira/browse/CASSANDRA-19982?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
David Stringer updated CASSANDRA-19982: --------------------------------------- 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: {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 was: 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: > 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 > 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