From 061b465d3408e1111694f821419f6c426642d45e Mon Sep 17 00:00:00 2001 From: Vadim Ogievetsky Date: Fri, 7 Jun 2019 08:32:40 -0700 Subject: [PATCH] Web console: Normalize ingestion spec type (#7847) * Normalize ingestion spec types * also normalize on direct spec change --- web-console/src/utils/ingestion-spec.tsx | 13 +++++++++++ web-console/src/utils/sampler.ts | 3 +-- .../views/load-data-view/load-data-view.tsx | 23 +++++++++++++------ 3 files changed, 30 insertions(+), 9 deletions(-) diff --git a/web-console/src/utils/ingestion-spec.tsx b/web-console/src/utils/ingestion-spec.tsx index 355dc390a09..1328a372810 100644 --- a/web-console/src/utils/ingestion-spec.tsx +++ b/web-console/src/utils/ingestion-spec.tsx @@ -147,6 +147,19 @@ export function changeParallel(spec: IngestionSpec, parallel: boolean): Ingestio return newSpec; } +/** + * Make sure that the types are set in the root, ioConfig, and tuningConfig + * @param spec + */ +export function normalizeSpecType(spec: IngestionSpec) { + const specType = getSpecType(spec); + if (!specType) return spec; + if (!deepGet(spec, 'type')) spec = deepSet(spec, 'type', specType); + if (!deepGet(spec, 'ioConfig.type')) spec = deepSet(spec, 'ioConfig.type', specType); + if (!deepGet(spec, 'tuningConfig.type')) spec = deepSet(spec, 'tuningConfig.type', specType); + return spec; +} + const PARSE_SPEC_FORM_FIELDS: Field[] = [ { name: 'format', diff --git a/web-console/src/utils/sampler.ts b/web-console/src/utils/sampler.ts index cff22b95ae9..c20109ae6ef 100644 --- a/web-console/src/utils/sampler.ts +++ b/web-console/src/utils/sampler.ts @@ -29,8 +29,7 @@ import { ParseSpec, Transform, TransformSpec } from './ingestion-spec'; -import { deepGet, deepSet, shallowCopy, whitelistKeys } from './object-change'; -import { QueryState } from './query-state'; +import { deepGet, deepSet, whitelistKeys } from './object-change'; const SAMPLER_URL = `/druid/indexer/v1/sampler`; const BASE_SAMPLER_CONFIG: SamplerConfig = { 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 299e451c79f..39f6b7f7e00 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 @@ -86,7 +86,7 @@ import { issueWithIoConfig, issueWithParser, joinFilter, - MetricSpec, + MetricSpec, normalizeSpecType, Parser, ParseSpec, parseSpecHasFlatten, @@ -284,9 +284,14 @@ export class LoadDataView extends React.PureComponent => { + const { initSupervisorId } = this.props; + try { - const resp = await axios.get(`/druid/indexer/v1/supervisor/${this.props.initSupervisorId}`); - this.updateSpec(resp.data); + const resp = await axios.get(`/druid/indexer/v1/supervisor/${initSupervisorId}`); + this.updateSpec(normalizeSpecType(resp.data)); this.updateStage('json-spec'); } catch (e) { AppToaster.show({ @@ -2362,9 +2369,11 @@ export class LoadDataView extends React.PureComponent => { + const { initTaskId } = this.props; + try { - const resp = await axios.get(`/druid/indexer/v1/task/${this.props.initTaskId}`); - this.updateSpec(resp.data.payload.spec); + const resp = await axios.get(`/druid/indexer/v1/task/${initTaskId}`); + this.updateSpec(normalizeSpecType(resp.data.payload.spec)); this.updateStage('json-spec'); } catch (e) { AppToaster.show({ @@ -2388,7 +2397,7 @@ export class LoadDataView extends React.PureComponent { if (!s) return; - this.updateSpec(s); + this.updateSpec(normalizeSpecType(s)); }} height="100%" />