diff --git a/processing/src/main/java/io/druid/query/select/SelectQueryQueryToolChest.java b/processing/src/main/java/io/druid/query/select/SelectQueryQueryToolChest.java index da15120e8df..bc6da76de27 100644 --- a/processing/src/main/java/io/druid/query/select/SelectQueryQueryToolChest.java +++ b/processing/src/main/java/io/druid/query/select/SelectQueryQueryToolChest.java @@ -208,9 +208,11 @@ public class SelectQueryQueryToolChest extends QueryToolChest configSupplier = Suppliers.ofInstance(new SelectQueryConfig(true)); + + private static final SelectQueryQueryToolChest toolChest = new SelectQueryQueryToolChest( + new DefaultObjectMapper(), + QueryRunnerTestHelper.NoopIntervalChunkingQueryRunnerDecorator(), + configSupplier + ); + + @Test + public void testComputeCacheKeyWithDifferentSortOrer() throws Exception + { + final SelectQuery query1 = Druids.newSelectQueryBuilder() + .dataSource("dummy") + .dimensions(Collections.singletonList("testDim")) + .intervals(SelectQueryRunnerTest.I_0112_0114) + .granularity(QueryRunnerTestHelper.allGran) + .pagingSpec(PagingSpec.newSpec(3)) + .descending(false) + .build(); + + final SelectQuery query2 = Druids.newSelectQueryBuilder() + .dataSource("dummy") + .dimensions(Collections.singletonList("testDim")) + .intervals(SelectQueryRunnerTest.I_0112_0114) + .granularity(QueryRunnerTestHelper.allGran) + .pagingSpec(PagingSpec.newSpec(3)) + .descending(true) + .build(); + + final CacheStrategy, Object, SelectQuery> strategy1 = toolChest.getCacheStrategy(query1); + Assert.assertNotNull(strategy1); + final CacheStrategy, Object, SelectQuery> strategy2 = toolChest.getCacheStrategy(query2); + Assert.assertNotNull(strategy2); + + Assert.assertFalse(Arrays.equals(strategy1.computeCacheKey(query1), strategy2.computeCacheKey(query2))); + } +}