diff --git a/x-pack/plugins/lens/public/indexpattern_plugin/dimension_panel.test.tsx b/x-pack/plugins/lens/public/indexpattern_plugin/dimension_panel.test.tsx index 751ac3a9678f9..6a3020dffcee0 100644 --- a/x-pack/plugins/lens/public/indexpattern_plugin/dimension_panel.test.tsx +++ b/x-pack/plugins/lens/public/indexpattern_plugin/dimension_panel.test.tsx @@ -55,12 +55,12 @@ describe('IndexPatternDimensionPanel', () => { columns: { col1: { operationId: 'op1', - label: 'Value of timestamp', + label: 'Date Histogram of timestamp', dataType: 'date', - isBucketed: false, + isBucketed: true, // Private - operationType: 'value', + operationType: 'date_histogram', sourceField: 'timestamp', }, }, @@ -169,17 +169,14 @@ describe('IndexPatternDimensionPanel', () => { ); expect( - wrapper.find('[data-test-subj="lns-indexPatternDimension-value"]').prop('color') + wrapper.find('[data-test-subj="lns-indexPatternDimension-date_histogram"]').prop('color') ).toEqual('primary'); expect( - wrapper.find('[data-test-subj="lns-indexPatternDimension-value"]').prop('isDisabled') + wrapper.find('[data-test-subj="lns-indexPatternDimension-date_histogram"]').prop('isDisabled') ).toEqual(false); expect( wrapper.find('[data-test-subj="lns-indexPatternDimension-terms"]').prop('isDisabled') ).toEqual(true); - expect( - wrapper.find('[data-test-subj="lns-indexPatternDimension-date_histogram"]').prop('isDisabled') - ).toEqual(false); expect( wrapper.find('[data-test-subj="lns-indexPatternDimension-sum"]').prop('isDisabled') ).toEqual(true); @@ -271,11 +268,6 @@ describe('IndexPatternDimensionPanel', () => { ...state.columns, col2: expect.objectContaining({ operationId: firstField.value, - label: 'Value of bytes', - dataType: 'number', - isBucketed: false, - operationType: 'value', - sourceField: 'bytes', }), }, columnOrder: ['col1', 'col2'], diff --git a/x-pack/plugins/lens/public/indexpattern_plugin/indexpattern.test.tsx b/x-pack/plugins/lens/public/indexpattern_plugin/indexpattern.test.tsx index 00ee692981dde..f918a16fd8825 100644 --- a/x-pack/plugins/lens/public/indexpattern_plugin/indexpattern.test.tsx +++ b/x-pack/plugins/lens/public/indexpattern_plugin/indexpattern.test.tsx @@ -119,10 +119,10 @@ describe('IndexPattern Data Source', () => { operationId: 'op1', label: 'My Op', dataType: 'string', - isBucketed: false, + isBucketed: true, // Private - operationType: 'value', + operationType: 'terms', sourceField: 'op', }, }, @@ -208,39 +208,6 @@ describe('IndexPattern Data Source', () => { expect(indexPatternDatasource.toExpression(state)).toEqual(null); }); - it('should generate an expression for a values query', async () => { - const queryPersistedState: IndexPatternPersistedState = { - currentIndexPatternId: '1', - columnOrder: ['col1', 'col2'], - columns: { - col1: { - operationId: 'op1', - label: 'My Op', - dataType: 'string', - isBucketed: false, - - // Private - operationType: 'value', - sourceField: 'source', - }, - col2: { - operationId: 'op2', - label: 'My Op 2', - dataType: 'number', - isBucketed: false, - - // Private - operationType: 'value', - sourceField: 'bytes', - }, - }, - }; - const state = await indexPatternDatasource.initialize(queryPersistedState); - expect(indexPatternDatasource.toExpression(state)).toMatchInlineSnapshot( - `"esdocs index=\\"my-fake-index-pattern\\" fields=\\"source, bytes\\" sort=\\"source, DESC\\" | lens_rename_columns idMap='{\\"source\\":\\"col1\\",\\"bytes\\":\\"col2\\"}'"` - ); - }); - it('should generate an expression for an aggregated query', async () => { const queryPersistedState: IndexPatternPersistedState = { currentIndexPatternId: '1', @@ -303,7 +270,7 @@ describe('IndexPattern Data Source', () => { id: 'op1', label: 'My Op', dataType: 'string', - isBucketed: false, + isBucketed: true, } as Operation); }); }); diff --git a/x-pack/plugins/lens/public/indexpattern_plugin/indexpattern.tsx b/x-pack/plugins/lens/public/indexpattern_plugin/indexpattern.tsx index 04bee936d7ff3..671b3576c7271 100644 --- a/x-pack/plugins/lens/public/indexpattern_plugin/indexpattern.tsx +++ b/x-pack/plugins/lens/public/indexpattern_plugin/indexpattern.tsx @@ -22,15 +22,7 @@ import { ChildDragDropProvider, DragDrop } from '../drag_drop'; import { toExpression } from './to_expression'; import { IndexPatternDimensionPanel } from './dimension_panel'; -export type OperationType = - | 'value' - | 'terms' - | 'date_histogram' - | 'sum' - | 'avg' - | 'min' - | 'max' - | 'count'; +export type OperationType = 'terms' | 'date_histogram' | 'sum' | 'avg' | 'min' | 'max' | 'count'; export interface IndexPatternColumn { // Public diff --git a/x-pack/plugins/lens/public/indexpattern_plugin/operations.test.ts b/x-pack/plugins/lens/public/indexpattern_plugin/operations.test.ts index 9bc64b8b24e38..09ff0ed27832b 100644 --- a/x-pack/plugins/lens/public/indexpattern_plugin/operations.test.ts +++ b/x-pack/plugins/lens/public/indexpattern_plugin/operations.test.ts @@ -45,7 +45,7 @@ describe('getOperationTypesForField', () => { aggregatable: true, searchable: true, }) - ).toEqual(expect.arrayContaining(['value', 'terms'])); + ).toEqual(expect.arrayContaining(['terms'])); }); it('should return operations on numbers', () => { @@ -56,7 +56,7 @@ describe('getOperationTypesForField', () => { aggregatable: true, searchable: true, }) - ).toEqual(expect.arrayContaining(['value', 'avg', 'sum', 'min', 'max'])); + ).toEqual(expect.arrayContaining(['avg', 'sum', 'min', 'max'])); }); it('should return operations on dates', () => { @@ -67,7 +67,7 @@ describe('getOperationTypesForField', () => { aggregatable: true, searchable: true, }) - ).toEqual(expect.arrayContaining(['value', 'date_histogram'])); + ).toEqual(expect.arrayContaining(['date_histogram'])); }); it('should return no operations on unknown types', () => { @@ -149,12 +149,12 @@ describe('getOperationTypesForField', () => { columns: { col1: { operationId: 'op1', - label: 'Value of timestamp', + label: 'Date Histogram of timestamp', dataType: 'date', - isBucketed: false, + isBucketed: true, // Private - operationType: 'value', + operationType: 'date_histogram', sourceField: 'timestamp', }, }, @@ -172,10 +172,6 @@ describe('getOperationTypesForField', () => { expect(columns.map(col => [col.sourceField, col.operationType])).toMatchInlineSnapshot(` Array [ - Array [ - "bytes", - "value", - ], Array [ "bytes", "sum", @@ -196,18 +192,10 @@ Array [ "documents", "count", ], - Array [ - "source", - "value", - ], Array [ "source", "terms", ], - Array [ - "timestamp", - "value", - ], Array [ "timestamp", "date_histogram", @@ -228,12 +216,12 @@ describe('getColumnOrder', () => { getColumnOrder({ col1: { operationId: 'op1', - label: 'Value of timestamp', - dataType: 'string', - isBucketed: false, + label: 'Date Histogram of timestamp', + dataType: 'date', + isBucketed: true, // Private - operationType: 'value', + operationType: 'date_histogram', sourceField: 'timestamp', }, }) @@ -250,8 +238,8 @@ describe('getColumnOrder', () => { isBucketed: true, // Private - operationType: 'value', - sourceField: 'timestamp', + operationType: 'terms', + sourceField: 'category', }, col2: { operationId: 'op2', @@ -260,7 +248,7 @@ describe('getColumnOrder', () => { isBucketed: false, // Private - operationType: 'value', + operationType: 'avg', sourceField: 'bytes', }, col3: { @@ -287,8 +275,8 @@ describe('getColumnOrder', () => { isBucketed: true, // Private - operationType: 'value', - sourceField: 'timestamp', + operationType: 'terms', + sourceField: 'category', suggestedOrder: 2, }, col2: { @@ -298,7 +286,7 @@ describe('getColumnOrder', () => { isBucketed: false, // Private - operationType: 'value', + operationType: 'avg', sourceField: 'bytes', suggestedOrder: 0, }, diff --git a/x-pack/plugins/lens/public/indexpattern_plugin/operations.ts b/x-pack/plugins/lens/public/indexpattern_plugin/operations.ts index 4a0df7a6a977a..6b252eb65fc51 100644 --- a/x-pack/plugins/lens/public/indexpattern_plugin/operations.ts +++ b/x-pack/plugins/lens/public/indexpattern_plugin/operations.ts @@ -15,7 +15,8 @@ import { } from './indexpattern'; export function getOperations(): OperationType[] { - return ['value', 'terms', 'date_histogram', 'sum', 'avg', 'min', 'max', 'count']; + // Raw value is not listed in the MVP + return ['terms', 'date_histogram', 'sum', 'avg', 'min', 'max', 'count']; } export function getOperationDisplay(): Record< @@ -27,17 +28,6 @@ export function getOperationDisplay(): Record< } > { return { - value: { - type: 'value', - displayName: i18n.translate('xpack.lens.indexPattern.value', { - defaultMessage: 'Value', - }), - ofName: name => - i18n.translate('xpack.lens.indexPattern.valueOf', { - defaultMessage: 'Value of {name}', - values: { name }, - }), - }, terms: { type: 'terms', displayName: i18n.translate('xpack.lens.indexPattern.terms', { @@ -132,19 +122,17 @@ export function getOperationTypesForField({ switch (type) { case 'date': - return ['value', 'date_histogram']; + return ['date_histogram']; case 'number': - return ['value', 'sum', 'avg', 'min', 'max']; + return ['sum', 'avg', 'min', 'max']; case 'string': - return ['value', 'terms']; + return ['terms']; } return []; } export function getOperationResultType({ type }: IndexPatternField, op: OperationType): DataType { switch (op) { - case 'value': - return type as DataType; case 'avg': case 'min': case 'max': diff --git a/x-pack/plugins/lens/public/indexpattern_plugin/to_expression.ts b/x-pack/plugins/lens/public/indexpattern_plugin/to_expression.ts index 142dbb19a78c3..3890eb32a2468 100644 --- a/x-pack/plugins/lens/public/indexpattern_plugin/to_expression.ts +++ b/x-pack/plugins/lens/public/indexpattern_plugin/to_expression.ts @@ -13,23 +13,9 @@ export function toExpression(state: IndexPatternPrivateState) { return null; } - const fieldNames = state.columnOrder.map(col => state.columns[col].sourceField); const sortedColumns = state.columnOrder.map(col => state.columns[col]); - const indexName = state.indexPatterns[state.currentIndexPatternId].title; - - if (sortedColumns.every(({ operationType }) => operationType === 'value')) { - const idMap = fieldNames.reduce( - (currentIdMap, fieldName, index) => ({ - ...currentIdMap, - [fieldName]: state.columnOrder[index], - }), - {} as Record - ); - return `esdocs index="${indexName}" fields="${fieldNames.join(', ')}" sort="${ - fieldNames[0] - }, DESC" | lens_rename_columns idMap='${JSON.stringify(idMap)}'`; - } else if (sortedColumns.length) { + if (sortedColumns.length) { const firstMetric = sortedColumns.findIndex(({ isBucketed }) => !isBucketed); const aggs = sortedColumns.map((col, index) => { if (col.operationType === 'date_histogram') {