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);
|
||||
aggFlags.add(false);
|
||||
needsReverses.add(false);
|
||||
final ValueType type = dimensions.get(i).getOutputType();
|
||||
isNumericField.add(ValueType.isNumeric(type));
|
||||
comparators.add(StringComparators.LEXICOGRAPHIC);
|
||||
boolean isNumeric = ValueType.isNumeric(dimensions.get(i).getOutputType());
|
||||
isNumericField.add(isNumeric);
|
||||
if (isNumeric) {
|
||||
comparators.add(StringComparators.NUMERIC);
|
||||
} else {
|
||||
comparators.add(StringComparators.LEXICOGRAPHIC);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -9952,6 +9952,85 @@ public class GroupByQueryRunnerTest
|
|||
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
|
||||
public void testMergeResultsWithLimitPushDown()
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue