mirror of
https://github.com/apache/druid.git
synced 2025-02-17 07:25:02 +00:00
Web console: Normalize ingestion spec type (#7847)
* Normalize ingestion spec types * also normalize on direct spec change
This commit is contained in:
parent
df01335789
commit
061b465d34
@ -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<ParseSpec>[] = [
|
||||
{
|
||||
name: 'format',
|
||||
|
@ -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 = {
|
||||
|
@ -86,7 +86,7 @@ import {
|
||||
issueWithIoConfig,
|
||||
issueWithParser,
|
||||
joinFilter,
|
||||
MetricSpec,
|
||||
MetricSpec, normalizeSpecType,
|
||||
Parser,
|
||||
ParseSpec,
|
||||
parseSpecHasFlatten,
|
||||
@ -284,9 +284,14 @@ export class LoadDataView extends React.PureComponent<LoadDataViewProps, LoadDat
|
||||
if (this.props.initTaskId) {
|
||||
this.updateStage('loading');
|
||||
this.getTaskJson();
|
||||
|
||||
} else if (this.props.initSupervisorId) {
|
||||
this.updateStage('loading');
|
||||
this.getSupervisorJson(); } else this.updateStage('connect');
|
||||
this.getSupervisorJson();
|
||||
|
||||
} else {
|
||||
this.updateStage('connect');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -2349,9 +2354,11 @@ export class LoadDataView extends React.PureComponent<LoadDataViewProps, LoadDat
|
||||
|
||||
// ==================================================================
|
||||
private getSupervisorJson = async (): Promise<void> => {
|
||||
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<LoadDataViewProps, LoadDat
|
||||
}
|
||||
|
||||
private getTaskJson = async (): Promise<void> => {
|
||||
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<LoadDataViewProps, LoadDat
|
||||
value={spec}
|
||||
onChange={(s) => {
|
||||
if (!s) return;
|
||||
this.updateSpec(s);
|
||||
this.updateSpec(normalizeSpecType(s));
|
||||
}}
|
||||
height="100%"
|
||||
/>
|
||||
|
Loading…
x
Reference in New Issue
Block a user