From cbe2b44e29f1dba0b1882a6afe771cca85083278 Mon Sep 17 00:00:00 2001 From: Chi Cao Minh Date: Mon, 28 Sep 2020 17:15:48 -0700 Subject: [PATCH] Compaction config UI optional numShards (#10446) * Compaction config UI optional numShards Specifying `numShards` for hashed partitions is no longer required after https://github.com/apache/druid/pull/10419. Update the UI to make `numShards` an optional field for hash partitions. * Update snapshot --- web-console/e2e-tests/auto-compaction.spec.ts | 2 +- .../e2e-tests/component/datasources/compaction.ts | 6 ++++-- .../__snapshots__/compaction-dialog.spec.tsx.snap | 6 +----- .../src/dialogs/compaction-dialog/compaction-dialog.tsx | 9 +-------- web-console/src/utils/ingestion-spec.tsx | 5 ----- 5 files changed, 7 insertions(+), 21 deletions(-) diff --git a/web-console/e2e-tests/auto-compaction.spec.ts b/web-console/e2e-tests/auto-compaction.spec.ts index e608d1cad91..edcf6a8d6ed 100644 --- a/web-console/e2e-tests/auto-compaction.spec.ts +++ b/web-console/e2e-tests/auto-compaction.spec.ts @@ -68,7 +68,7 @@ describe('Auto-compaction', () => { const compactionConfig = new CompactionConfig({ skipOffsetFromLatest: 'PT0S', partitionsSpec: new CompactionHashPartitionsSpec({ - numShards: 1, + numShards: null, }), }); await configureCompaction(page, datasourceName, compactionConfig); diff --git a/web-console/e2e-tests/component/datasources/compaction.ts b/web-console/e2e-tests/component/datasources/compaction.ts index 6aa1a952613..c22285dee1b 100644 --- a/web-console/e2e-tests/component/datasources/compaction.ts +++ b/web-console/e2e-tests/component/datasources/compaction.ts @@ -37,7 +37,9 @@ export class CompactionHashPartitionsSpec implements CompactionPartitionsSpec { async apply(page: playwright.Page): Promise { await setInput(page, PARTITIONING_TYPE, this.type); - await setInput(page, 'Num shards', String(this.numShards)); + if (this.numShards != null) { + await setInput(page, 'Num shards', String(this.numShards)); + } } } @@ -48,7 +50,7 @@ async function setInput(page: playwright.Page, label: string, value: string): Pr } interface CompactionHashPartitionsSpecProps { - readonly numShards: number; + readonly numShards: number | null; } export interface CompactionHashPartitionsSpec extends CompactionHashPartitionsSpecProps {} diff --git a/web-console/src/dialogs/compaction-dialog/__snapshots__/compaction-dialog.spec.tsx.snap b/web-console/src/dialogs/compaction-dialog/__snapshots__/compaction-dialog.spec.tsx.snap index 3a0a83841f6..4ff3b516efc 100644 --- a/web-console/src/dialogs/compaction-dialog/__snapshots__/compaction-dialog.spec.tsx.snap +++ b/web-console/src/dialogs/compaction-dialog/__snapshots__/compaction-dialog.spec.tsx.snap @@ -92,7 +92,6 @@ exports[`CompactionDialog matches snapshot with compactionConfig (dynamic partit , "label": "Num shards", "name": "tuningConfig.partitionsSpec.numShards", - "required": true, "type": "number", }, Object { @@ -319,7 +318,6 @@ exports[`CompactionDialog matches snapshot with compactionConfig (hashed partiti , "label": "Num shards", "name": "tuningConfig.partitionsSpec.numShards", - "required": true, "type": "number", }, Object { @@ -444,7 +442,7 @@ exports[`CompactionDialog matches snapshot with compactionConfig (hashed partiti text="Close" /> , "label": "Num shards", "name": "tuningConfig.partitionsSpec.numShards", - "required": true, "type": "number", }, Object { @@ -773,7 +770,6 @@ exports[`CompactionDialog matches snapshot without compactionConfig 1`] = ` , "label": "Num shards", "name": "tuningConfig.partitionsSpec.numShards", - "required": true, "type": "number", }, Object { diff --git a/web-console/src/dialogs/compaction-dialog/compaction-dialog.tsx b/web-console/src/dialogs/compaction-dialog/compaction-dialog.tsx index 1798565a2f8..2c0f704ad48 100644 --- a/web-console/src/dialogs/compaction-dialog/compaction-dialog.tsx +++ b/web-console/src/dialogs/compaction-dialog/compaction-dialog.tsx @@ -77,7 +77,6 @@ const COMPACTION_CONFIG_FIELDS: Field[] = [ name: 'tuningConfig.partitionsSpec.numShards', label: 'Num shards', type: 'number', - required: true, // ToDo: this will no longer be required after https://github.com/apache/druid/pull/10419 is merged defined: (t: CompactionConfig) => deepGet(t, 'tuningConfig.partitionsSpec.type') === 'hashed', info: ( <> @@ -211,13 +210,7 @@ function validCompactionConfig(compactionConfig: CompactionConfig): boolean { deepGet(compactionConfig, 'tuningConfig.partitionsSpec.type') || 'dynamic'; switch (partitionsSpecType) { // case 'dynamic': // Nothing to check for dynamic - case 'hashed': - // ToDo: this will no longer be required after https://github.com/apache/druid/pull/10419 is merged - if (!deepGet(compactionConfig, 'tuningConfig.partitionsSpec.numShards')) { - return false; - } - break; - + // case 'hashed': // Nothing to check for hashed case 'single_dim': if (!deepGet(compactionConfig, 'tuningConfig.partitionsSpec.partitionDimension')) { return false; diff --git a/web-console/src/utils/ingestion-spec.tsx b/web-console/src/utils/ingestion-spec.tsx index d6d90bb64d9..a4cdbb800a4 100644 --- a/web-console/src/utils/ingestion-spec.tsx +++ b/web-console/src/utils/ingestion-spec.tsx @@ -2114,10 +2114,6 @@ export function invalidTuningConfig(tuningConfig: TuningConfig, intervals: any): if (!intervals) return true; switch (deepGet(tuningConfig, 'partitionsSpec.type')) { - case 'hashed': - if (!deepGet(tuningConfig, 'partitionsSpec.numShards')) return true; - break; - case 'single_dim': if (!deepGet(tuningConfig, 'partitionsSpec.partitionDimension')) return true; const hasTargetRowsPerSegment = Boolean( @@ -2190,7 +2186,6 @@ export function getPartitionRelatedTuningSpecFormFields( label: 'Num shards', type: 'number', defined: (t: TuningConfig) => deepGet(t, 'partitionsSpec.type') === 'hashed', - required: true, info: ( <> Directly specify the number of shards to create. If this is specified and 'intervals'