clean up spec before reopening in data loader (#9536)

This commit is contained in:
Vadim Ogievetsky 2020-03-23 16:57:51 -07:00 committed by GitHub
parent d8833316c4
commit cdf4a26904
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 37 additions and 3 deletions

View File

@ -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: {},
},
});
});
});

View File

@ -294,6 +294,17 @@ export function normalizeSpec(spec: Partial<IngestionSpec>): 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<InputFormat>[] = [
{
name: 'type',

View File

@ -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<LoadDataViewProps, LoadDat
try {
const resp = await axios.get(`/druid/indexer/v1/supervisor/${initSupervisorId}`);
this.updateSpec(resp.data);
this.updateSpec(cleanSpec(resp.data));
this.setState({ continueToSpec: true });
this.updateStep('spec');
} catch (e) {
@ -2967,7 +2968,7 @@ export class LoadDataView extends React.PureComponent<LoadDataViewProps, LoadDat
try {
const resp = await axios.get(`/druid/indexer/v1/task/${initTaskId}`);
this.updateSpec(resp.data.payload);
this.updateSpec(cleanSpec(resp.data.payload));
this.setState({ continueToSpec: true });
this.updateStep('spec');
} catch (e) {