|
28 | 28 | import org.elasticsearch.xpack.core.transform.transforms.pivot.GroupConfig; |
29 | 29 | import org.elasticsearch.xpack.core.transform.transforms.pivot.GroupConfigTests; |
30 | 30 | import org.elasticsearch.xpack.core.transform.transforms.pivot.HistogramGroupSourceTests; |
| 31 | +import org.elasticsearch.xpack.core.transform.transforms.pivot.ScriptConfigTests; |
31 | 32 | import org.elasticsearch.xpack.core.transform.transforms.pivot.SingleGroupSource; |
32 | 33 | import org.elasticsearch.xpack.core.transform.transforms.pivot.TermsGroupSource; |
33 | 34 | import org.elasticsearch.xpack.core.transform.transforms.pivot.TermsGroupSourceTests; |
@@ -80,7 +81,7 @@ public void testPageSize() throws IOException { |
80 | 81 | assertEquals(10, getCompositeAggregationBuilder(collector.buildChangesQuery(new SearchSourceBuilder(), null, 10)).size()); |
81 | 82 |
|
82 | 83 | // a terms group_by is limited by terms query |
83 | | - SingleGroupSource termsGroupBy = TermsGroupSourceTests.randomTermsGroupSource(); |
| 84 | + SingleGroupSource termsGroupBy = TermsGroupSourceTests.randomTermsGroupSourceNoScript(); |
84 | 85 | groups.put("terms", termsGroupBy); |
85 | 86 |
|
86 | 87 | collector = CompositeBucketsChangeCollector.buildChangeCollector(getCompositeAggregation(groups), groups, null); |
@@ -196,6 +197,24 @@ public void testDateHistogramFieldCollector() throws IOException { |
196 | 197 | assertNull(queryBuilder); |
197 | 198 | } |
198 | 199 |
|
| 200 | + public void testNoTermsFieldCollectorForScripts() throws IOException { |
| 201 | + Map<String, SingleGroupSource> groups = new LinkedHashMap<>(); |
| 202 | + |
| 203 | + // terms with value script |
| 204 | + SingleGroupSource termsGroupBy = new TermsGroupSource("id", ScriptConfigTests.randomScriptConfig(), false); |
| 205 | + groups.put("id", termsGroupBy); |
| 206 | + |
| 207 | + Map<String, FieldCollector> fieldCollectors = CompositeBucketsChangeCollector.createFieldCollectors(groups, null); |
| 208 | + assertTrue(fieldCollectors.isEmpty()); |
| 209 | + |
| 210 | + // terms with only a script |
| 211 | + termsGroupBy = new TermsGroupSource(null, ScriptConfigTests.randomScriptConfig(), false); |
| 212 | + groups.put("id", termsGroupBy); |
| 213 | + |
| 214 | + fieldCollectors = CompositeBucketsChangeCollector.createFieldCollectors(groups, null); |
| 215 | + assertTrue(fieldCollectors.isEmpty()); |
| 216 | + } |
| 217 | + |
199 | 218 | private static CompositeAggregationBuilder getCompositeAggregation(Map<String, SingleGroupSource> groups) throws IOException { |
200 | 219 | CompositeAggregationBuilder compositeAggregation; |
201 | 220 | try (XContentBuilder builder = jsonBuilder()) { |
|
0 commit comments