Skip to content

Commit c0a7ce3

Browse files
committed
CC5 Fix for o.a.c.distributed.test.GenericOrderByTest.testOrderBy
Reverts previous "CC5 fix AbstractReadQueryToCQLTest" that changed SelectStatement.getQuery with a union of CC and CASSANDRA-19968 logic about when to use range or slice commands; The incorrect ordering results are possibly due to a conflict with the C* 19968 logic and "CNDB-12308: Remove index-based sorting at CQL level" ; Restoring the CC logic maintains CC expectation about ordering of results; AbstractReadQueryToCQLTest is changed to expect CQL representations based on use of range commands instead of slice commands.
1 parent 8c75023 commit c0a7ce3

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

src/java/org/apache/cassandra/cql3/statements/SelectStatement.java

+4-10
Original file line numberDiff line numberDiff line change
@@ -494,25 +494,19 @@ public ReadQuery getQuery(QueryOptions options,
494494
int userOffset,
495495
AggregationSpecification aggregationSpec)
496496
{
497+
boolean isPartitionRangeQuery = restrictions.isKeyRange() || restrictions.usesSecondaryIndexing() || restrictions.isDisjunction();
498+
497499
RowFilter rowFilter = getRowFilter(options, state);
498500
DataLimits limit = getDataLimits(state, userLimit, perPartitionLimit, userOffset, aggregationSpec);
499501

500502
ReadQuery query;
501-
if (restrictions.isKeyRange())
503+
if (isPartitionRangeQuery)
502504
{
503-
if (restrictions.usesSecondaryIndexing() && !SchemaConstants.isLocalSystemKeyspace(table.keyspace))
505+
if (restrictions.isKeyRange() && restrictions.usesSecondaryIndexing() && !SchemaConstants.isLocalSystemKeyspace(table.keyspace))
504506
Guardrails.nonPartitionRestrictedIndexQueryEnabled.ensureEnabled(state);
505507

506508
query = getRangeCommand(options, state, columnFilter, rowFilter, limit, nowInSec);
507509
}
508-
else if (restrictions.usesSecondaryIndexing() && !rowFilter.isStrict())
509-
{
510-
query = getRangeCommand(options, state, columnFilter, rowFilter, limit, nowInSec);
511-
}
512-
else if (restrictions.isDisjunction())
513-
{
514-
query = getRangeCommand(options, state, columnFilter, rowFilter, limit, nowInSec);
515-
}
516510
else
517511
{
518512
query = getSliceCommands(options, state, columnFilter, rowFilter, limit, nowInSec);

test/unit/org/apache/cassandra/db/AbstractReadQueryToCQLStringTest.java

+12-6
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,8 @@ public void testSkinnyTable() throws Throwable
110110
"SELECT * FROM %s WHERE v1 = 1 AND v2 = 2 ALLOW FILTERING",
111111
"SELECT * FROM %s WHERE v2 = 2 AND v1 = 1 ALLOW FILTERING");
112112
test("SELECT * FROM %s WHERE token(k) > 0 AND v1 = 1");
113-
test("SELECT * FROM %s WHERE k = 0 AND v1 = 1");
113+
test("SELECT * FROM %s WHERE k = 0 AND v1 = 1",
114+
"SELECT * FROM %s WHERE token(k) >= token(0) AND token(k) <= token(0) AND v1 = 1 ALLOW FILTERING");
114115

115116
// grouped partition-directed queries, maybe producing multiple queries
116117
test("SELECT * FROM %s WHERE k IN (0)",
@@ -202,7 +203,9 @@ public void testSkinnyTableWithMulticolumnKey() throws Throwable
202203
test("SELECT * FROM %s WHERE token(k1, k2) > 0 AND k2 = 2");
203204
test("SELECT * FROM %s WHERE token(k1, k2) > 0 AND v1 = 1");
204205
test("SELECT * FROM %s WHERE token(k1, k2) > 0 AND v2 = 2");
205-
test("SELECT * FROM %s WHERE k1 = 1 AND k2 = 2 AND v1 = 1");
206+
// test("SELECT * FROM %s WHERE k1 = 1 AND k2 = 2 AND v1 = 1");
207+
test("SELECT * FROM %s WHERE k1 = 1 AND k2 = 2 AND v1 = 1",
208+
"SELECT * FROM %s WHERE token(k1, k2) >= token(1, 2) AND token(k1, k2) <= token(1, 2) AND v1 = 1 ALLOW FILTERING");
206209

207210
// grouped partition-directed queries, maybe producing multiple queries
208211
test("SELECT * FROM %s WHERE k1 IN (1) AND k2 = 2",
@@ -304,9 +307,10 @@ public void testWideTable() throws Throwable
304307
"SELECT * FROM %s WHERE v1 = 1 AND v2 = 2 ALLOW FILTERING",
305308
"SELECT * FROM %s WHERE v2 = 2 AND v1 = 1 ALLOW FILTERING");
306309
test("SELECT * FROM %s WHERE token(k) > 0 AND v1 = 1");
307-
test("SELECT * FROM %s WHERE k = 0 AND v1 = 1");
310+
test("SELECT * FROM %s WHERE k = 0 AND v1 = 1",
311+
"SELECT * FROM %s WHERE token(k) >= token(0) AND token(k) <= token(0) AND v1 = 1 ALLOW FILTERING");
308312
test("SELECT * FROM %s WHERE k = 0 AND v1 = 1 AND c = 1",
309-
"SELECT * FROM %s WHERE k = 0 AND c = 1 AND v1 = 1 ALLOW FILTERING");
313+
"SELECT * FROM %s WHERE token(k) >= token(0) AND token(k) <= token(0) AND c = 1 AND v1 = 1 ALLOW FILTERING");
310314

311315
// grouped partition-directed queries, maybe producing multiple queries
312316
test("SELECT * FROM %s WHERE k IN (0)",
@@ -462,8 +466,10 @@ public void testWideTableWithMulticolumnKey() throws Throwable
462466
"SELECT * FROM %s WHERE v1 = 1 AND v2 = 2 ALLOW FILTERING",
463467
"SELECT * FROM %s WHERE v2 = 2 AND v1 = 1 ALLOW FILTERING");
464468
test("SELECT * FROM %s WHERE token(k1, k2) > 0 AND v1 = 1");
465-
test("SELECT * FROM %s WHERE k1 = 1 AND k2 = 2 AND v1 = 1");
466-
test("SELECT * FROM %s WHERE k1 = 1 AND k2 = 2 AND c1 = 1 AND v1 = 1");
469+
test("SELECT * FROM %s WHERE k1 = 1 AND k2 = 2 AND v1 = 1",
470+
"SELECT * FROM %s WHERE token(k1, k2) >= token(1, 2) AND token(k1, k2) <= token(1, 2) AND v1 = 1 ALLOW FILTERING");
471+
test("SELECT * FROM %s WHERE k1 = 1 AND k2 = 2 AND c1 = 1 AND v1 = 1",
472+
"SELECT * FROM %s WHERE token(k1, k2) >= token(1, 2) AND token(k1, k2) <= token(1, 2) AND c1 = 1 AND v1 = 1 ALLOW FILTERING");
467473

468474
// grouped partition-directed queries, maybe producing multiple queries
469475
test("SELECT * FROM %s WHERE k1 IN (1) AND k2 IN (2)",

0 commit comments

Comments
 (0)