Fix auto-aggregation exception in case of empty results
@@ -51,6 +51,7 @@ public class AutoAggregationHandler {
try {
DataResult newest = getSingleRecord(Order.DESC);
DataResult oldest = getSingleRecord(Order.ASC);
+ if (newest.getTotal() > 0) {
String sampleField = getSampleField(newest);
Integer count = getCount(sampleField);
if (count <= MAX_RETURN_LIMIT) {
@@ -64,6 +65,9 @@ public class AutoAggregationHandler {
queryParams.update(QP_TIME_INTERVAL, aggValue + "ms");
return disableAutoAgg(queryParams);
}
+ } else {
+ return disableAutoAgg(this.queryParams);
+ }
} catch(ParseException e){
e.printStackTrace();
}
