AggregationQueryBuilder extends ExpressionNodeVisitor<AggregationBuilder, Object> { public Map<String, ExprType> buildTypeMapping( List<NamedAggregator> namedAggregatorList, List<NamedExpression> groupByList) { ImmutableMap.Builder<String, ExprType> builder = new ImmutableMap.Builder<>(); namedAggregatorList.forEach(agg -> builder.put(agg.getName(), agg.type())); groupByList.forEach(group -> builder.put(group.getName(), group.type())); return builder.build(); } AggregationQueryBuilder(
      ExpressionSerializer serializer); List<AggregationBuilder> buildAggregationBuilder(List<NamedAggregator> namedAggregatorList,
                                                          List<NamedExpression> groupByList); Map<String, ExprType> buildTypeMapping(
      List<NamedAggregator> namedAggregatorList,
      List<NamedExpression> groupByList); static final int AGGREGATION_BUCKET_SIZE; }
@Test void should_build_type_mapping_for_field_reference() { assertThat( buildTypeMapping(Arrays.asList( named("avg(age)", new AvgAggregator(Arrays.asList(ref("age", INTEGER)), INTEGER))), Arrays.asList(named("name", ref("name", STRING)))), containsInAnyOrder( map("avg(age)", INTEGER), map("name", STRING) )); }
@Test void should_build_type_mapping_for_field_reference_of_keyword() { assertThat( buildTypeMapping(Arrays.asList( named("avg(age)", new AvgAggregator(Arrays.asList(ref("age", INTEGER)), INTEGER))), Arrays.asList(named("name", ref("name", ES_TEXT_KEYWORD)))), containsInAnyOrder( map("avg(age)", INTEGER), map("name", ES_TEXT_KEYWORD) )); }
@Test void should_build_type_mapping_for_expression() { assertThat( buildTypeMapping(Arrays.asList( named("avg(balance)", new AvgAggregator( Arrays.asList(dsl.abs(ref("balance", INTEGER))), INTEGER))), Arrays.asList(named("age", dsl.asin(ref("age", INTEGER))))), containsInAnyOrder( map("avg(balance)", INTEGER), map("age", DOUBLE) )); }
@Test void should_build_type_mapping_without_bucket() { assertThat( buildTypeMapping(Arrays.asList( named("avg(balance)", new AvgAggregator( Arrays.asList(ref("balance", INTEGER)), INTEGER))), Collections.emptyList()), containsInAnyOrder( map("avg(balance)", INTEGER) )); }