Skip to content

Commit

Permalink
[ML] do not throw an error when agg is not supported by UI (#72685) (#…
Browse files Browse the repository at this point in the history
…72806)

Co-authored-by: Dima Arnautov <dmitrii.arnautov@elastic.co>
  • Loading branch information
peteharverson and darnautov committed Jul 22, 2020
1 parent 5e0c492 commit f7bf42f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
4 changes: 0 additions & 4 deletions x-pack/plugins/transform/public/app/common/pivot_aggs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
4 changes: 2 additions & 2 deletions x-pack/plugins/transform/public/app/common/pivot_aggs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down

0 comments on commit f7bf42f

Please sign in to comment.