mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
[Lens] fix transition date_histogram/last_value -> top values/last_value (#86429)
This commit is contained in:
parent
3c284fbff3
commit
cea865f5a9
2 changed files with 34 additions and 2 deletions
|
@ -90,7 +90,8 @@ export const termsOperation: OperationDefinition<TermsIndexPatternColumn, 'field
|
|||
buildColumn({ layer, field, indexPattern }) {
|
||||
const existingMetricColumn = Object.entries(layer.columns)
|
||||
.filter(
|
||||
([columnId, column]) => column && !column.isBucketed && !isReferenced(layer, columnId)
|
||||
([columnId, column]) =>
|
||||
column && !isReferenced(layer, columnId) && isSortableByColumn(column)
|
||||
)
|
||||
.map(([id]) => id)[0];
|
||||
|
||||
|
|
|
@ -305,7 +305,7 @@ describe('terms', () => {
|
|||
expect(termsColumn.params.otherBucket).toEqual(false);
|
||||
});
|
||||
|
||||
it('should use existing metric column as order column', () => {
|
||||
it('should use existing sortable metric column as order column', () => {
|
||||
const termsColumn = termsOperation.buildColumn({
|
||||
indexPattern: createMockedIndexPattern(),
|
||||
layer: {
|
||||
|
@ -335,6 +335,37 @@ describe('terms', () => {
|
|||
})
|
||||
);
|
||||
});
|
||||
it('should set alphabetical order type if metric column is of type last value', () => {
|
||||
const termsColumn = termsOperation.buildColumn({
|
||||
indexPattern: createMockedIndexPattern(),
|
||||
layer: {
|
||||
columns: {
|
||||
col1: {
|
||||
label: 'Last value of a',
|
||||
dataType: 'number',
|
||||
isBucketed: false,
|
||||
sourceField: 'a',
|
||||
operationType: 'last_value',
|
||||
params: {
|
||||
sortField: 'datefield',
|
||||
},
|
||||
},
|
||||
},
|
||||
columnOrder: [],
|
||||
indexPatternId: '',
|
||||
},
|
||||
field: {
|
||||
aggregatable: true,
|
||||
searchable: true,
|
||||
type: 'boolean',
|
||||
name: 'test',
|
||||
displayName: 'test',
|
||||
},
|
||||
});
|
||||
expect(termsColumn.params).toEqual(
|
||||
expect.objectContaining({ orderBy: { type: 'alphabetical' } })
|
||||
);
|
||||
});
|
||||
|
||||
it('should use the default size when there is an existing bucket', () => {
|
||||
const termsColumn = termsOperation.buildColumn({
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue