Skip to content

Commit e91e901

Browse files
author
Hendrik Muhs
committed
apply review comments
1 parent a5633bc commit e91e901

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/transforms/pivot/TransformAggregations.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,9 @@ public static String resolveTargetMapping(String aggregationType, String sourceT
194194
* Both mappings can contain _multiple_ entries, e.g. due to sub aggregations or because of aggregations creating multiple
195195
* values(e.g. percentiles)
196196
*
197+
* Note about order: aggregation can hit in multiple places (e.g. a multi value agg implement {@link ValuesSourceAggregationBuilder})
198+
* Be careful changing the order in this method
199+
*
197200
* @param agg the aggregation builder
198201
* @return a tuple with 2 mappings that maps the used field(s) and aggregation type(s)
199202
*/
@@ -214,7 +217,6 @@ public static Tuple<Map<String, String>, Map<String, String>> getAggregationInpu
214217
);
215218
}
216219

217-
// Note: order is important
218220
// does the agg specify output field names
219221
Optional<Set<String>> outputFieldNames = agg.getOutputFieldNames();
220222
if (outputFieldNames.isPresent()) {
@@ -224,7 +226,7 @@ public static Tuple<Map<String, String>, Map<String, String>> getAggregationInpu
224226
.collect(
225227
Collectors.toMap(
226228
outputField -> agg.getName() + "." + outputField,
227-
outputField -> { return outputField; },
229+
outputField -> outputField,
228230
(v1, v2) -> v1
229231
)
230232
),
@@ -233,7 +235,7 @@ public static Tuple<Map<String, String>, Map<String, String>> getAggregationInpu
233235
.collect(
234236
Collectors.toMap(
235237
outputField -> agg.getName() + "." + outputField,
236-
outputField -> { return agg.getType(); },
238+
outputField -> agg.getType(),
237239
(v1, v2) -> v1
238240
)
239241
)

x-pack/plugin/transform/src/test/java/org/elasticsearch/xpack/transform/transforms/pivot/AggregationResultUtilsTests.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -810,6 +810,12 @@ public void testNumericMultiValueAggExtractor() {
810810
.value(agg, Map.of("mv_metric.approx_answer", "double", "mv_metric.exact_answer", "long"), ""),
811811
equalTo(Map.of("approx_answer", Double.valueOf(42.2), "exact_answer", Long.valueOf(42)))
812812
);
813+
814+
assertThat(
815+
AggregationResultUtils.getExtractor(agg)
816+
.value(agg, Map.of("filter.mv_metric.approx_answer", "double", "filter.mv_metric.exact_answer", "long"), "filter"),
817+
equalTo(Map.of("approx_answer", Double.valueOf(42.2), "exact_answer", Long.valueOf(42)))
818+
);
813819
}
814820

815821
private ScriptedMetric createScriptedMetric(Object returnValue) {

0 commit comments

Comments
 (0)