Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix incorrect comparator usage in FinalizingFieldAccessPostAggregator #16555

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Prev Previous commit
permit nulls; restore stuff for unknown inputs
  • Loading branch information
kgyrtkirk committed Jun 10, 2024
commit c74481ab5dd35b7820e581cbdf632afb2d4e3d22
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.collect.Sets;
import org.apache.druid.error.DruidException;
import org.apache.commons.collections.comparators.NullComparator;
import org.apache.druid.java.util.common.guava.Comparators;
import org.apache.druid.query.aggregation.AggregatorFactory;
import org.apache.druid.query.aggregation.PostAggregator;
import org.apache.druid.query.cache.CacheKeyBuilder;
Expand Down Expand Up @@ -123,9 +124,12 @@ public FinalizingFieldAccessPostAggregator decorate(final Map<String, Aggregator
if (aggregators != null && aggregators.containsKey(fieldName)) {
theFinalizer = aggregators.get(fieldName)::finalizeComputation;
finalizedType = aggregators.get(fieldName).getResultType();
theComparator = ColumnTypeFactory.getInstance().getTypeStrategy(finalizedType);
theComparator = new NullComparator(ColumnTypeFactory.getInstance().getTypeStrategy(finalizedType));
} else {
throw DruidException.defensive("PostAggregator input column [%s] not found in aggregators!", fieldName);
// noinspection unchecked
theComparator = (Comparator) Comparators.naturalNullsFirst();
theFinalizer = Function.identity();
finalizedType = null;
}

return new FinalizingFieldAccessPostAggregator(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ public void testComputedWithFinalizing()
{
String aggName = "biily";
AggregatorFactory aggFactory = EasyMock.createMock(AggregatorFactory.class);
EasyMock.expect(aggFactory.getComparator()).andReturn(Comparators.naturalNullsFirst()).once();
EasyMock.expect(aggFactory.finalizeComputation("test")).andReturn(3L).once();
EasyMock.expect(aggFactory.getResultType()).andReturn(ColumnType.LONG).once();
EasyMock.replay(aggFactory);
Expand Down
Loading