Implementation:Apache Druid MaxTasksButton
| Knowledge Sources | |
|---|---|
| Domains | Web_Console, Query_Workbench |
| Last Updated | 2026-02-10 10:00 GMT |
Overview
MaxTasksButton is a React component that provides a dropdown button for configuring the maximum number of tasks for MSQ query execution.
Description
The component renders a BlueprintJS Popover with a menu allowing users to set the maxNumTasks query context parameter for multi-stage queries. It offers preset options (2, 3, 4, 5, 7, 9, 11, 17, 33, 65, 129 by default), a "full cluster capacity" option when cluster capacity is known, a custom numeric input dialog for arbitrary values, and a task assignment mode selector (max vs auto). The button label dynamically displays the current setting. Options exceeding the cluster capacity are automatically filtered out. Custom label functions for task counts and cluster capacity can be provided for flexible display.
Usage
Used in the workbench view toolbar to allow users to control parallelism of MSQ task execution before running a query. Appears alongside other query configuration controls.
Code Reference
Source Location
- Repository: Apache Druid
- File: web-console/src/views/workbench-view/max-tasks-button/max-tasks-button.tsx
- Lines: 1-194
Signature
export interface MaxTasksButtonProps extends Omit<ButtonProps, 'text' | 'rightIcon'> {
clusterCapacity: number | undefined;
queryContext: QueryContext;
changeQueryContext(queryContext: QueryContext): void;
defaultQueryContext: QueryContext;
menuHeader?: JSX.Element;
maxTasksLabelFn?: (maxNum: number) => { text: string; label?: string };
maxTasksOptions?: number[];
fullClusterCapacityLabelFn?: (clusterCapacity: number) => string;
}
export const MaxTasksButton = function MaxTasksButton(
props: MaxTasksButtonProps,
): JSX.Element;
Import
import { MaxTasksButton } from 'web-console/src/views/workbench-view/max-tasks-button/max-tasks-button';
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| clusterCapacity | number or undefined | No | Total number of available task slots in the cluster |
| queryContext | QueryContext | Yes | The current query context object containing maxNumTasks |
| changeQueryContext | (queryContext: QueryContext) => void | Yes | Callback to update the query context when a selection is made |
| defaultQueryContext | QueryContext | Yes | Default query context for deriving default task assignment |
| menuHeader | JSX.Element | No | Optional header element rendered at the top of the popover menu |
| maxTasksLabelFn | function | No | Custom label function for task count menu items |
| maxTasksOptions | number[] | No | Custom array of task count options (defaults to [2,3,4,5,7,9,11,17,33,65,129]) |
| fullClusterCapacityLabelFn | function | No | Custom label function for the full cluster capacity option |
Outputs
| Name | Type | Description |
|---|---|---|
| JSX.Element | Fragment | A Popover-wrapped Button with task count menu and optional NumericInputDialog for custom values |
Usage Examples
Rendering the max tasks button with cluster capacity
<MaxTasksButton
clusterCapacity={32}
queryContext={currentContext}
changeQueryContext={(ctx) => setQueryContext(ctx)}
defaultQueryContext={defaultContext}
/>