Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/plugins/data/public/search/tabify/get_columns.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,4 +161,20 @@ describe('get columns', () => {
'Sum of @timestamp',
]);
});

test('should not fail if there is no field for date histogram agg', () => {
const columns = tabifyGetColumns(
createAggConfigs([
{
type: 'date_histogram',
schema: 'segment',
params: {},
},
{ type: 'sum', schema: 'metric', params: { field: '@timestamp' } },
]).aggs,
false
);

expect(columns.map((c) => c.name)).toEqual(['', 'Sum of @timestamp']);
});
});
9 changes: 8 additions & 1 deletion src/plugins/data/public/search/tabify/get_columns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,17 @@ import { IAggConfig } from '../aggs';
import { TabbedAggColumn } from './types';

const getColumn = (agg: IAggConfig, i: number): TabbedAggColumn => {
let name = '';
try {
name = agg.makeLabel();
} catch (e) {
// skip the case when makeLabel throws an error (e.x. no appropriate field for an aggregation)
}

return {
aggConfig: agg,
id: `col-${i}-${agg.id}`,
name: agg.makeLabel(),
name,
};
};

Expand Down