mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
fix bug (#144716)
Co-authored-by: Stratoula Kalafateli <efstratia.kalafateli@elastic.co>
This commit is contained in:
parent
f436d936e3
commit
a897698860
2 changed files with 24 additions and 1 deletions
|
@ -271,7 +271,7 @@ export const termsOperation: OperationDefinition<
|
|||
const orderColumn = layer.columns[column.params.orderBy.columnId];
|
||||
orderBy = String(orderedColumnIds.indexOf(column.params.orderBy.columnId));
|
||||
// percentile rank with non integer value should default to alphabetical order
|
||||
if (!isPercentileRankSortable(orderColumn)) {
|
||||
if (!orderColumn || !isPercentileRankSortable(orderColumn)) {
|
||||
orderBy = '_key';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -352,6 +352,29 @@ describe('terms', () => {
|
|||
);
|
||||
});
|
||||
|
||||
it('should default to alphabetical sort when the referenced column does not exist anymore', () => {
|
||||
const termsColumn = layer.columns.col1 as TermsIndexPatternColumn;
|
||||
const esAggsFn = termsOperation.toEsAggsFn(
|
||||
{
|
||||
...termsColumn,
|
||||
params: { ...termsColumn.params, orderBy: { type: 'column', columnId: 'unknownCol' } },
|
||||
},
|
||||
'col1',
|
||||
{} as IndexPattern,
|
||||
layer,
|
||||
uiSettingsMock,
|
||||
['col1', 'col2']
|
||||
);
|
||||
expect(esAggsFn).toEqual(
|
||||
expect.objectContaining({
|
||||
function: 'aggTerms',
|
||||
arguments: expect.objectContaining({
|
||||
orderBy: ['_key'],
|
||||
}),
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
it('should not enable missing bucket if other bucket is not set', () => {
|
||||
const termsColumn = layer.columns.col1 as TermsIndexPatternColumn;
|
||||
const esAggsFn = termsOperation.toEsAggsFn(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue