private TemplateDruidQuery buildInnerQuery(MetricField sourceMetric,TemplateDruidQuery innerDependentQuery){
  Set<Aggregation> newInnerAggregations=convertSketchesToSketchMerges(innerDependentQuery.getAggregations());
  Set<PostAggregation> newInnerPostAggregations=new LinkedHashSet<>();
  if (sourceMetric instanceof PostAggregation) {
    newInnerPostAggregations.add((PostAggregation)sourceMetric);
  }
  TemplateDruidQuery innerQuery=innerDependentQuery;
  innerQuery=innerQuery.withAggregations(newInnerAggregations);
  innerQuery=innerQuery.withPostAggregations(newInnerPostAggregations);
  innerQuery=innerQuery.merge(buildTimeGrainCounterQuery());
  return innerQuery;
}

private TemplateDruidQuery buildInnerQuery ( MetricField sourceMetric , TemplateDruidQuery innerDependentQuery ) { Set < Aggregation > newInnerAggregations = convertSketchesToSketchMerges ( innerDependentQuery . getAggregations ( ) ) ; Set < PostAggregation > newInnerPostAggregations = new LinkedHashSet < > ( ) ; if ( sourceMetric instanceof PostAggregation ) { newInnerPostAggregations . add ( ( PostAggregation ) sourceMetric ) ; } TemplateDruidQuery innerQuery = innerDependentQuery ; innerQuery = innerQuery . withAggregations ( newInnerAggregations ) ; innerQuery = innerQuery . withPostAggregations ( newInnerPostAggregations ) ; innerQuery = innerQuery . merge ( buildTimeGrainCounterQuery ( ) ) ; return innerQuery ; }
create the inner query for an average .
