Jump to content

Connect Leeroopedia MCP: Equip your AI agents to search best practices, build plans, verify code, diagnose failures, and look up hyperparameter defaults.

Implementation:Apache Druid QueryTab ProcessQuery

From Leeroopedia


Knowledge Sources
Domains SQL_Querying, Query_Processing
Last Updated 2026-02-10 00:00 GMT

Overview

Concrete query dispatch function within the QueryTab component that routes queries to the appropriate Druid execution engine.

Description

The processQuery method in QueryTab handles the complete query execution lifecycle:

  1. Determines the execution engine from the WorkbenchQuery context
  2. Dispatches to submitTaskQuery() (MSQ), queryDruidSql() (native SQL), or queryDruidRune() (native JSON)
  3. Manages cancellation via AbortController
  4. Handles errors by wrapping them as DruidError with line/column positions
  5. Stores results as Execution (MSQ) or QueryResult (native) for the result pane
  6. Records the query in WorkbenchHistory after execution

Usage

This function is called when the user clicks the Run button in the Workbench. It is internal to the QueryTab component.

Code Reference

Source Location

  • Repository: Apache Druid
  • File: web-console/src/views/workbench-view/query-tab/query-tab.tsx
  • Lines: L203-L361

Signature

// Internal to QueryTab component
private processQuery = async (): Promise<void> => {
  const { query } = this.state;
  const engine = query.engine;
  // Dispatches to appropriate execution function based on engine
}

// Execution functions called by processQuery:
// submitTaskQuery(options) → for 'sql-msq-task' and 'sql-msq-dart'
// queryDruidSql({ query, context }) → for 'sql-native'
// queryDruidRune(jsonQuery) → for 'native'

Import

// Internal to QueryTab — not independently importable
// Supporting functions:
import { submitTaskQuery } from '../../helpers/execution/sql-task-execution';
import { queryDruidSql, queryDruidRune } from '../../utils/druid-query';

I/O Contract

Inputs

Name Type Required Description
query WorkbenchQuery Yes Complete query with text, context, and engine selection

Outputs

Name Type Description
Execution Execution For MSQ queries: task with stages and progress
QueryResult QueryResult For native queries: column headers and row data
DruidError DruidError On failure: error code, message, line, and column for editor highlighting

Usage Examples

Query Execution Flow

// Triggered by Run button click in QueryTab:
// 1. User writes: SELECT COUNT(*) FROM "events" WHERE __time > CURRENT_TIMESTAMP - INTERVAL '1' DAY
// 2. Engine is set to 'sql-native' via RunPanel
// 3. processQuery dispatches to queryDruidSql:

const result = await queryDruidSql({
  query: 'SELECT COUNT(*) FROM "events" WHERE __time > CURRENT_TIMESTAMP - INTERVAL \'1\' DAY',
  context: { sqlTimeZone: 'America/New_York', useCache: true },
});
// result = QueryResult with columns: ['EXPR$0'] and rows: [[42]]

// 4. For MSQ engine:
const execution = await submitTaskQuery({
  query: 'SELECT * FROM "events" LIMIT 10000',
  context: { selectDestination: 'durableStorage' },
});
// execution = Execution with stages, timing, and result preview

Related Pages

Implements Principle

Requires Environment

Uses Heuristic

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment