From cdf4a26904b5129e038a1f32944101c51df0ec58 Mon Sep 17 00:00:00 2001 From: Vadim Ogievetsky Date: Mon, 23 Mar 2020 16:57:51 -0700 Subject: [PATCH] clean up spec before reopening in data loader (#9536) --- web-console/src/utils/ingestion-spec.spec.ts | 24 ++++++++++++++++++- web-console/src/utils/ingestion-spec.tsx | 11 +++++++++ .../views/load-data-view/load-data-view.tsx | 5 ++-- 3 files changed, 37 insertions(+), 3 deletions(-) diff --git a/web-console/src/utils/ingestion-spec.spec.ts b/web-console/src/utils/ingestion-spec.spec.ts index 1399aeb6557..19d3911ed1b 100644 --- a/web-console/src/utils/ingestion-spec.spec.ts +++ b/web-console/src/utils/ingestion-spec.spec.ts @@ -16,7 +16,7 @@ * limitations under the License. */ -import { downgradeSpec, upgradeSpec } from './ingestion-spec'; +import { cleanSpec, downgradeSpec, upgradeSpec } from './ingestion-spec'; describe('ingestion-spec', () => { const oldSpec = { @@ -98,4 +98,26 @@ describe('ingestion-spec', () => { it('round trips', () => { expect(downgradeSpec(upgradeSpec(oldSpec))).toMatchObject(oldSpec); }); + + it('cleanSpec', () => { + expect( + cleanSpec({ + type: 'index_parallel', + id: 'index_parallel_coronavirus_hamlcmea_2020-03-19T00:56:12.175Z', + groupId: 'index_parallel_coronavirus_hamlcmea_2020-03-19T00:56:12.175Z', + resource: { + availabilityGroup: 'index_parallel_coronavirus_hamlcmea_2020-03-19T00:56:12.175Z', + requiredCapacity: 1, + }, + spec: { + dataSchema: {}, + }, + } as any), + ).toEqual({ + type: 'index_parallel', + spec: { + dataSchema: {}, + }, + }); + }); }); diff --git a/web-console/src/utils/ingestion-spec.tsx b/web-console/src/utils/ingestion-spec.tsx index afbe27bc00d..92068816537 100644 --- a/web-console/src/utils/ingestion-spec.tsx +++ b/web-console/src/utils/ingestion-spec.tsx @@ -294,6 +294,17 @@ export function normalizeSpec(spec: Partial): IngestionSpec { return spec as IngestionSpec; } +/** + * Make sure that any extra junk in the spec other than 'type' and 'spec' is removed + * @param spec + */ +export function cleanSpec(spec: IngestionSpec): IngestionSpec { + return { + type: spec.type, + spec: spec.spec, + }; +} + const INPUT_FORMAT_FORM_FIELDS: Field[] = [ { name: 'type', diff --git a/web-console/src/views/load-data-view/load-data-view.tsx b/web-console/src/views/load-data-view/load-data-view.tsx index 991ebcddb2c..113b1044ba2 100644 --- a/web-console/src/views/load-data-view/load-data-view.tsx +++ b/web-console/src/views/load-data-view/load-data-view.tsx @@ -71,6 +71,7 @@ import { updateSchemaWithSample } from '../../utils/druid-type'; import { adjustIngestionSpec, adjustTuningConfig, + cleanSpec, DimensionMode, DimensionSpec, DimensionsSpec, @@ -2951,7 +2952,7 @@ export class LoadDataView extends React.PureComponent