mirror of https://github.com/apache/druid.git
fix sorting for resultRow object when numeric dimension not in limitSpec (#8645)
This commit is contained in:
parent
2f20799868
commit
46ddaf3aa1
|
@ -867,9 +867,13 @@ public class RowBasedGrouperHelper
|
||||||
fieldIndices.add(i);
|
fieldIndices.add(i);
|
||||||
aggFlags.add(false);
|
aggFlags.add(false);
|
||||||
needsReverses.add(false);
|
needsReverses.add(false);
|
||||||
final ValueType type = dimensions.get(i).getOutputType();
|
boolean isNumeric = ValueType.isNumeric(dimensions.get(i).getOutputType());
|
||||||
isNumericField.add(ValueType.isNumeric(type));
|
isNumericField.add(isNumeric);
|
||||||
comparators.add(StringComparators.LEXICOGRAPHIC);
|
if (isNumeric) {
|
||||||
|
comparators.add(StringComparators.NUMERIC);
|
||||||
|
} else {
|
||||||
|
comparators.add(StringComparators.LEXICOGRAPHIC);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9952,6 +9952,85 @@ public class GroupByQueryRunnerTest
|
||||||
TestHelper.assertExpectedObjects(expectedResults, results, "order-limit");
|
TestHelper.assertExpectedObjects(expectedResults, results, "order-limit");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGroupByLimitPushDownWithLongDimensionNotInLimitSpec()
|
||||||
|
{
|
||||||
|
// Cannot vectorize due to extraction dimension spec.
|
||||||
|
cannotVectorize();
|
||||||
|
|
||||||
|
if (!config.getDefaultStrategy().equals(GroupByStrategySelector.STRATEGY_V2)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
GroupByQuery query = makeQueryBuilder()
|
||||||
|
.setDataSource(QueryRunnerTestHelper.DATA_SOURCE)
|
||||||
|
.setGranularity(QueryRunnerTestHelper.ALL_GRAN).setDimensions(
|
||||||
|
new ExtractionDimensionSpec("quality", "qualityLen", ValueType.LONG, StrlenExtractionFn.instance())
|
||||||
|
)
|
||||||
|
.setInterval(QueryRunnerTestHelper.FULL_ON_INTERVAL_SPEC)
|
||||||
|
.setLimitSpec(
|
||||||
|
new DefaultLimitSpec(
|
||||||
|
Collections.EMPTY_LIST,
|
||||||
|
6
|
||||||
|
)
|
||||||
|
).setAggregatorSpecs(QueryRunnerTestHelper.ROWS_COUNT)
|
||||||
|
.overrideContext(ImmutableMap.of(GroupByQueryConfig.CTX_KEY_FORCE_LIMIT_PUSH_DOWN, true))
|
||||||
|
.build();
|
||||||
|
|
||||||
|
List<ResultRow> expectedResults = Arrays.asList(
|
||||||
|
makeRow(
|
||||||
|
query,
|
||||||
|
"1970-01-01T00:00:00.000Z",
|
||||||
|
"qualityLen",
|
||||||
|
4L,
|
||||||
|
"rows",
|
||||||
|
93L
|
||||||
|
),
|
||||||
|
makeRow(
|
||||||
|
query,
|
||||||
|
"1970-01-01T00:00:00.000Z",
|
||||||
|
"qualityLen",
|
||||||
|
6L,
|
||||||
|
"rows",
|
||||||
|
186L
|
||||||
|
),
|
||||||
|
makeRow(
|
||||||
|
query,
|
||||||
|
"1970-01-01T00:00:00.000Z",
|
||||||
|
"qualityLen",
|
||||||
|
7L,
|
||||||
|
"rows",
|
||||||
|
279L
|
||||||
|
),
|
||||||
|
makeRow(
|
||||||
|
query,
|
||||||
|
"1970-01-01T00:00:00.000Z",
|
||||||
|
"qualityLen",
|
||||||
|
8L,
|
||||||
|
"rows",
|
||||||
|
93L
|
||||||
|
),
|
||||||
|
makeRow(
|
||||||
|
query,
|
||||||
|
"1970-01-01T00:00:00.000Z",
|
||||||
|
"qualityLen",
|
||||||
|
9L,
|
||||||
|
"rows",
|
||||||
|
279L
|
||||||
|
),
|
||||||
|
makeRow(
|
||||||
|
query,
|
||||||
|
"1970-01-01T00:00:00.000Z",
|
||||||
|
"qualityLen",
|
||||||
|
10L,
|
||||||
|
"rows",
|
||||||
|
186L
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
Iterable<ResultRow> results = GroupByQueryRunnerTestHelper.runQuery(factory, runner, query);
|
||||||
|
TestHelper.assertExpectedObjects(expectedResults, results, "order-limit");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMergeResultsWithLimitPushDown()
|
public void testMergeResultsWithLimitPushDown()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue