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
This commit is contained in:
Chi Cao Minh 2020-09-28 17:15:48 -07:00 committed by GitHub
parent d16c78ba98
commit cbe2b44e29
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 7 additions and 21 deletions

View File

@ -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);

View File

@ -37,7 +37,9 @@ export class CompactionHashPartitionsSpec implements CompactionPartitionsSpec {
async apply(page: playwright.Page): Promise<void> {
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 {}

View File

@ -92,7 +92,6 @@ exports[`CompactionDialog matches snapshot with compactionConfig (dynamic partit
</React.Fragment>,
"label": "Num shards",
"name": "tuningConfig.partitionsSpec.numShards",
"required": true,
"type": "number",
},
Object {
@ -319,7 +318,6 @@ exports[`CompactionDialog matches snapshot with compactionConfig (hashed partiti
</React.Fragment>,
"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"
/>
<Blueprint3.Button
disabled={true}
disabled={false}
intent="primary"
onClick={[Function]}
text="Submit"
@ -546,7 +544,6 @@ exports[`CompactionDialog matches snapshot with compactionConfig (single_dim par
</React.Fragment>,
"label": "Num shards",
"name": "tuningConfig.partitionsSpec.numShards",
"required": true,
"type": "number",
},
Object {
@ -773,7 +770,6 @@ exports[`CompactionDialog matches snapshot without compactionConfig 1`] = `
</React.Fragment>,
"label": "Num shards",
"name": "tuningConfig.partitionsSpec.numShards",
"required": true,
"type": "number",
},
Object {

View File

@ -77,7 +77,6 @@ const COMPACTION_CONFIG_FIELDS: Field<CompactionConfig>[] = [
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;

View File

@ -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'