[ML] do not throw an error when agg is not supported by UI (#72685)

This commit is contained in:
Dima Arnautov 2020-07-22 01:03:27 +02:00 committed by GitHub
parent b930cef489
commit b3f1595331
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 6 deletions

View file

@ -11,10 +11,6 @@ import {
} from '../sections/create_transform/components/step_define/common/filter_agg/components';
describe('getAggConfigFromEsAgg', () => {
test('should throw an error for unsupported agg', () => {
expect(() => getAggConfigFromEsAgg({ terms: {} }, 'test')).toThrowError();
});
test('should return a common config if the agg does not have a custom config defined', () => {
expect(getAggConfigFromEsAgg({ avg: { field: 'region' } }, 'test_1')).toEqual({
agg: 'avg',

View file

@ -110,8 +110,8 @@ export function getAggConfigFromEsAgg(
// Find the main aggregation key
const agg = aggKeys.find((aggKey) => aggKey !== 'aggs');
if (!isPivotSupportedAggs(agg)) {
throw new Error(`Aggregation "${agg}" is not supported`);
if (agg === undefined) {
throw new Error(`Aggregation key is required`);
}
const commonConfig: PivotAggsConfigBase = {