diff --git a/extensions-core/stats/src/main/java/org/apache/druid/query/aggregation/variance/StandardDeviationPostAggregator.java b/extensions-core/stats/src/main/java/org/apache/druid/query/aggregation/variance/StandardDeviationPostAggregator.java index 2d011673467..559f0c4e8f4 100644 --- a/extensions-core/stats/src/main/java/org/apache/druid/query/aggregation/variance/StandardDeviationPostAggregator.java +++ b/extensions-core/stats/src/main/java/org/apache/druid/query/aggregation/variance/StandardDeviationPostAggregator.java @@ -79,7 +79,11 @@ public class StandardDeviationPostAggregator implements PostAggregator @Nullable public Double compute(Map combinedAggregators) { - Double variance = ((VarianceAggregatorCollector) combinedAggregators.get(fieldName)).getVariance(isVariancePop); + Object varianceAggregatorCollector = combinedAggregators.get(fieldName); + if (!(varianceAggregatorCollector instanceof VarianceAggregatorCollector)) { + return NullHandling.defaultDoubleValue(); + } + Double variance = ((VarianceAggregatorCollector) varianceAggregatorCollector).getVariance(isVariancePop); return variance == null ? NullHandling.defaultDoubleValue() : (Double) Math.sqrt(variance); }