From bf16ea41acbd615715974841f65dff83356c0623 Mon Sep 17 00:00:00 2001 From: Hendrik Muhs Date: Wed, 4 Nov 2020 16:39:06 +0100 Subject: [PATCH] [Transform] weighted avg should map to double (#64586) weighted avg like avg returns always a double value, this changes changes the output mapping from dynamic to double --- .../transform/transforms/pivot/TransformAggregations.java | 2 +- .../transforms/pivot/TransformAggregationsTests.java | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/transforms/pivot/TransformAggregations.java b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/transforms/pivot/TransformAggregations.java index 87bf3cc5c473a..92524086fa2a3 100644 --- a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/transforms/pivot/TransformAggregations.java +++ b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/transforms/pivot/TransformAggregations.java @@ -103,7 +103,7 @@ enum AggregationType { GEO_CENTROID("geo_centroid", GEO_POINT), GEO_BOUNDS("geo_bounds", GEO_SHAPE), SCRIPTED_METRIC("scripted_metric", DYNAMIC), - WEIGHTED_AVG("weighted_avg", DYNAMIC), + WEIGHTED_AVG("weighted_avg", DOUBLE), BUCKET_SELECTOR("bucket_selector", DYNAMIC), BUCKET_SCRIPT("bucket_script", DYNAMIC), PERCENTILES("percentiles", DOUBLE), diff --git a/x-pack/plugin/transform/src/test/java/org/elasticsearch/xpack/transform/transforms/pivot/TransformAggregationsTests.java b/x-pack/plugin/transform/src/test/java/org/elasticsearch/xpack/transform/transforms/pivot/TransformAggregationsTests.java index 43d4938a7fccd..ec20a6994e980 100644 --- a/x-pack/plugin/transform/src/test/java/org/elasticsearch/xpack/transform/transforms/pivot/TransformAggregationsTests.java +++ b/x-pack/plugin/transform/src/test/java/org/elasticsearch/xpack/transform/transforms/pivot/TransformAggregationsTests.java @@ -78,8 +78,9 @@ public void testResolveTargetMapping() { assertEquals("_dynamic", TransformAggregations.resolveTargetMapping("bucket_selector", "int")); // weighted_avg - assertEquals("_dynamic", TransformAggregations.resolveTargetMapping("weighted_avg", null)); - assertEquals("_dynamic", TransformAggregations.resolveTargetMapping("weighted_avg", "double")); + assertEquals("double", TransformAggregations.resolveTargetMapping("weighted_avg", null)); + assertEquals("double", TransformAggregations.resolveTargetMapping("weighted_avg", "double")); + assertEquals("double", TransformAggregations.resolveTargetMapping("weighted_avg", "int")); // percentile assertEquals("double", TransformAggregations.resolveTargetMapping("percentiles", null));