[ML] Transforms: Fix pivot preview table mapping. (#60609)
- Fixes regression caused by elastic/elasticsearch#53572. - Adjusts the TS mappings and code to reflect the newly returned API response. - Re-enables functional tests.
This commit is contained in:
parent
404e941e63
commit
b2b5fcedcc
|
@ -36,6 +36,7 @@ export {
|
|||
TRANSFORM_MODE,
|
||||
} from './transform_stats';
|
||||
export { getDiscoverUrl } from './navigation';
|
||||
export { GetTransformsResponse, PreviewData, PreviewMappings } from './pivot_preview';
|
||||
export {
|
||||
getEsAggFromAggConfig,
|
||||
isPivotAggsConfigWithUiSupport,
|
||||
|
|
29
x-pack/plugins/transform/public/app/common/pivot_preview.ts
Normal file
29
x-pack/plugins/transform/public/app/common/pivot_preview.ts
Normal file
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
import { ES_FIELD_TYPES } from '../../../../../../src/plugins/data/public';
|
||||
|
||||
import { Dictionary } from '../../../common/types/common';
|
||||
|
||||
interface EsMappingType {
|
||||
type: ES_FIELD_TYPES;
|
||||
}
|
||||
|
||||
export type PreviewItem = Dictionary<any>;
|
||||
export type PreviewData = PreviewItem[];
|
||||
export interface PreviewMappings {
|
||||
properties: Dictionary<EsMappingType>;
|
||||
}
|
||||
|
||||
export interface GetTransformsResponse {
|
||||
preview: PreviewData;
|
||||
generated_dest_index: {
|
||||
mappings: PreviewMappings;
|
||||
// Not in use yet
|
||||
aliases: any;
|
||||
settings: any;
|
||||
};
|
||||
}
|
|
@ -9,8 +9,7 @@ import { useEffect, useState } from 'react';
|
|||
import { dictionaryToArray } from '../../../../common/types/common';
|
||||
import { useApi } from '../../hooks/use_api';
|
||||
|
||||
import { Dictionary } from '../../../../common/types/common';
|
||||
import { IndexPattern, ES_FIELD_TYPES } from '../../../../../../../src/plugins/data/public';
|
||||
import { IndexPattern } from '../../../../../../../src/plugins/data/public';
|
||||
|
||||
import {
|
||||
getPreviewRequestBody,
|
||||
|
@ -18,6 +17,8 @@ import {
|
|||
PivotAggsConfigDict,
|
||||
PivotGroupByConfigDict,
|
||||
PivotQuery,
|
||||
PreviewData,
|
||||
PreviewMappings,
|
||||
} from '../../common';
|
||||
|
||||
export enum PIVOT_PREVIEW_STATUS {
|
||||
|
@ -27,16 +28,6 @@ export enum PIVOT_PREVIEW_STATUS {
|
|||
ERROR,
|
||||
}
|
||||
|
||||
interface EsMappingType {
|
||||
type: ES_FIELD_TYPES;
|
||||
}
|
||||
|
||||
export type PreviewItem = Dictionary<any>;
|
||||
type PreviewData = PreviewItem[];
|
||||
interface PreviewMappings {
|
||||
properties: Dictionary<EsMappingType>;
|
||||
}
|
||||
|
||||
export interface UsePivotPreviewDataReturnType {
|
||||
errorMessage: string;
|
||||
status: PIVOT_PREVIEW_STATUS;
|
||||
|
@ -45,11 +36,6 @@ export interface UsePivotPreviewDataReturnType {
|
|||
previewRequest: PreviewRequestBody;
|
||||
}
|
||||
|
||||
export interface GetTransformsResponse {
|
||||
preview: PreviewData;
|
||||
mappings: PreviewMappings;
|
||||
}
|
||||
|
||||
export const usePivotPreviewData = (
|
||||
indexPatternTitle: IndexPattern['title'],
|
||||
query: PivotQuery,
|
||||
|
@ -77,9 +63,9 @@ export const usePivotPreviewData = (
|
|||
setStatus(PIVOT_PREVIEW_STATUS.LOADING);
|
||||
|
||||
try {
|
||||
const resp: GetTransformsResponse = await api.getTransformsPreview(previewRequest);
|
||||
const resp = await api.getTransformsPreview(previewRequest);
|
||||
setPreviewData(resp.preview);
|
||||
setPreviewMappings(resp.mappings);
|
||||
setPreviewMappings(resp.generated_dest_index.mappings);
|
||||
setStatus(PIVOT_PREVIEW_STATUS.LOADED);
|
||||
} catch (e) {
|
||||
setErrorMessage(JSON.stringify(e, null, 2));
|
||||
|
|
|
@ -8,7 +8,7 @@ import { TransformId, TransformEndpointRequest, TransformEndpointResult } from '
|
|||
import { API_BASE_PATH } from '../../../common/constants';
|
||||
|
||||
import { useAppDependencies } from '../app_dependencies';
|
||||
import { PreviewRequestBody } from '../common';
|
||||
import { GetTransformsResponse, PreviewRequestBody } from '../common';
|
||||
|
||||
import { EsIndex } from './use_api_types';
|
||||
|
||||
|
@ -37,7 +37,7 @@ export const useApi = () => {
|
|||
body: JSON.stringify(transformsInfo),
|
||||
});
|
||||
},
|
||||
getTransformsPreview(obj: PreviewRequestBody): Promise<any> {
|
||||
getTransformsPreview(obj: PreviewRequestBody): Promise<GetTransformsResponse> {
|
||||
return http.post(`${API_BASE_PATH}transforms/_preview`, { body: JSON.stringify(obj) });
|
||||
},
|
||||
startTransforms(transformsInfo: TransformEndpointRequest[]): Promise<TransformEndpointResult> {
|
||||
|
|
|
@ -8,8 +8,7 @@ import { FtrProviderContext } from '../../ftr_provider_context';
|
|||
export default function({ getService, loadTestFile }: FtrProviderContext) {
|
||||
const transform = getService('transform');
|
||||
|
||||
// prevent test failures with current ES snapshot, see https://github.com/elastic/kibana/issues/60516
|
||||
describe.skip('transform', function() {
|
||||
describe('transform', function() {
|
||||
this.tags(['ciGroup9', 'transform']);
|
||||
|
||||
before(async () => {
|
||||
|
|
Loading…
Reference in a new issue