This page describes SQL-based batch ingestion using the multi-stage query (MSQ) task engine, introduced in Druid 24.0. For a programmatic interface, use these APIs. For a user-friendly interface, use the Query view in the web console.
Submit a query
Submits SQL queries to the MSQ task engine for execution.SQL query string. Supports INSERT, REPLACE, and SELECT (experimental) statements.
Query context parameters for the MSQ engine including:
maxNumTasks: Maximum number of parallel tasksfinalizeAggregations: Whether to finalize aggregations during ingestionexecutionMode: Set to “ASYNC” for asynchronous execution
List of query parameters for parameterized queries.
Controller task ID for the submitted query.
Initial state of the query (typically “RUNNING”).
Get task status
Retrieves the current status of a query task.The controller task ID returned when submitting the query.
Current status: RUNNING, SUCCESS, or FAILED.
Task duration in milliseconds (-1 if still running).
Host and port information where the task is running.
Get task report
Retrieves the detailed task report including stages, statistics, and results.The controller task ID.
Query execution status including state, start time, duration, and worker information.
Array of query stage definitions and execution details.
Execution counters for rows processed, bytes transferred, and other metrics.
Information about segment loading after ingestion completes.
Report fields
Key fields in the task report:| Field | Description |
|---|---|
status.status | RUNNING, SUCCESS, or FAILED |
status.durationMs | Milliseconds elapsed since start |
status.workers | Information about worker tasks |
status.segmentLoadStatus.state | Segment loading state: INIT, WAITING, SUCCESS, FAILED, TIMED_OUT |
stages[].stageNumber | Stage identifier |
stages[].phase | Stage phase: NEW, READING_INPUT, POST_READING, RESULTS_COMPLETE, FAILED |
stages[].workerCount | Number of parallel workers for the stage |
counters | Row and byte counters per stage and worker |
Cancel a query task
Cancels a running query task.The task ID to cancel.
Query types
The MSQ task engine supports:INSERT statements
Insert data into a new or existing datasource:REPLACE statements
Replace data in a datasource for specific time ranges:SELECT statements (Experimental)
Plain SELECT queries are supported experimentally. Results are written to the task report:SELECT query results appear in
multiStageQuery.payload.results.results as an array of arrays. The format is subject to change.Context parameters
Important MSQ context parameters:| Parameter | Type | Description |
|---|---|---|
maxNumTasks | integer | Maximum number of worker tasks |
finalizeAggregations | boolean | Finalize aggregations during ingestion |
rowsInMemory | integer | Rows to buffer in memory |
segmentSortOrder | string | Column sort order for segments |
maxParseExceptions | integer | Maximum parse exceptions before failing |
executionMode | string | Set to “ASYNC” for async execution |
Error codes
Common error codes in task reports:| Error Code | Description |
|---|---|
TooManyWarnings | Exceeded warning threshold |
CannotParseExternalData | Failed to parse input data |
InsertCannotAllocateSegment | Cannot allocate segment for INSERT |
ColumnTypeNotSupported | Unsupported column type |
QueryNotSupported | Query type not supported by MSQ engine |