mirror of https://github.com/apache/druid.git
discard filter when processing subtotalsSpec (#7827)
This commit is contained in:
parent
d482da6e9b
commit
0493780799
|
@ -390,7 +390,7 @@ public class GroupByStrategyV2 implements GroupByStrategy
|
|||
final List<Closeable> closeOnExit = new ArrayList<>();
|
||||
|
||||
try {
|
||||
GroupByQuery queryWithoutSubtotalsSpec = query.withSubtotalsSpec(null);
|
||||
GroupByQuery queryWithoutSubtotalsSpec = query.withSubtotalsSpec(null).withDimFilter(null);
|
||||
List<List<String>> subtotals = query.getSubtotalsSpec();
|
||||
|
||||
Supplier<Grouper> grouperSupplier = Suppliers.memoize(
|
||||
|
|
|
@ -6787,6 +6787,96 @@ public class GroupByQueryRunnerTest
|
|||
TestHelper.assertExpectedObjects(expectedResults, results, "subtotal");
|
||||
}
|
||||
|
||||
// https://github.com/apache/incubator-druid/issues/7820
|
||||
@Test
|
||||
public void testGroupByWithSubtotalsSpecWithRenamedDimensionAndFilter()
|
||||
{
|
||||
if (!config.getDefaultStrategy().equals(GroupByStrategySelector.STRATEGY_V2)) {
|
||||
return;
|
||||
}
|
||||
|
||||
GroupByQuery query = GroupByQuery
|
||||
.builder()
|
||||
.setDataSource(QueryRunnerTestHelper.dataSource)
|
||||
.setQuerySegmentSpec(QueryRunnerTestHelper.firstToThird)
|
||||
.setVirtualColumns(new ExpressionVirtualColumn("alias", "quality", ValueType.STRING, TestExprMacroTable.INSTANCE))
|
||||
.setDimensions(Lists.newArrayList(
|
||||
new DefaultDimensionSpec("quality", "quality"),
|
||||
new DefaultDimensionSpec("market", "market"),
|
||||
new DefaultDimensionSpec("alias", "alias_renamed")
|
||||
))
|
||||
.setAggregatorSpecs(
|
||||
Arrays.asList(
|
||||
QueryRunnerTestHelper.rowsCount,
|
||||
new LongSumAggregatorFactory("idx", "index"),
|
||||
new FloatSumAggregatorFactory("idxFloat", "indexFloat"),
|
||||
new DoubleSumAggregatorFactory("idxDouble", "index")
|
||||
)
|
||||
)
|
||||
.setDimFilter(new SelectorDimFilter("alias", "automotive", null))
|
||||
.setGranularity(QueryRunnerTestHelper.dayGran)
|
||||
.setSubtotalsSpec(ImmutableList.of(
|
||||
ImmutableList.of("alias_renamed"),
|
||||
ImmutableList.of()
|
||||
))
|
||||
.build();
|
||||
|
||||
List<Row> expectedResults = Arrays.asList(
|
||||
GroupByQueryRunnerTestHelper.createExpectedRow(
|
||||
"2011-04-01",
|
||||
"alias_renamed",
|
||||
"automotive",
|
||||
"rows",
|
||||
1L,
|
||||
"idx",
|
||||
135L,
|
||||
"idxFloat",
|
||||
135.88510131835938f,
|
||||
"idxDouble",
|
||||
135.88510131835938d
|
||||
),
|
||||
GroupByQueryRunnerTestHelper.createExpectedRow(
|
||||
"2011-04-02",
|
||||
"alias_renamed",
|
||||
"automotive",
|
||||
"rows",
|
||||
1L,
|
||||
"idx",
|
||||
147L,
|
||||
"idxFloat",
|
||||
147.42593f,
|
||||
"idxDouble",
|
||||
147.42593d
|
||||
),
|
||||
|
||||
GroupByQueryRunnerTestHelper.createExpectedRow(
|
||||
"2011-04-01T00:00:00.000Z",
|
||||
"rows",
|
||||
1L,
|
||||
"idx",
|
||||
135L,
|
||||
"idxFloat",
|
||||
135.88510131835938f,
|
||||
"idxDouble",
|
||||
135.88510131835938d
|
||||
),
|
||||
GroupByQueryRunnerTestHelper.createExpectedRow(
|
||||
"2011-04-02T00:00:00.000Z",
|
||||
"rows",
|
||||
1L,
|
||||
"idx",
|
||||
147L,
|
||||
"idxFloat",
|
||||
147.42593f,
|
||||
"idxDouble",
|
||||
147.42593d
|
||||
)
|
||||
);
|
||||
|
||||
Iterable<Row> results = GroupByQueryRunnerTestHelper.runQuery(factory, runner, query);
|
||||
TestHelper.assertExpectedObjects(expectedResults, results, "subtotal");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGroupByWithSubtotalsSpecWithLongDimensionColumn()
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue