Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Apache Druid DruidSqlAceMode

From Leeroopedia


Knowledge Sources
Domains Web_Console, SQL_Editor
Last Updated 2026-02-10 10:00 GMT

Overview

DruidSqlAceMode defines and registers a custom Ace Editor syntax highlighting mode for Druid SQL (DSQL), providing keyword, function, data type, and operator colorization tailored to the Druid SQL dialect.

Description

The module exports the initAceDsqlMode function, which uses ace.define to register two Ace modules: the highlight rules ('ace/mode/dsql_highlight_rules') and the mode itself ('ace/mode/dsql'). The highlight rules combine SQL_KEYWORDS, SQL_CONSTANTS, SQL_DYNAMICS, SQL_FUNCTIONS, SQL_DATA_TYPES, and optionally available server-reported SQL functions into a keyword mapper that assigns token types for color coding. The tokenizer handles SQL comments (single-line -- and multi-line /* */), double-quoted column references, single-quoted string literals, numeric constants, and operators. The mode sets line comment style to '--' and returns empty completions (autocompletion is handled separately).

Usage

Initialized during application bootstrap (via the ace bootstrap module) and used as the editor mode for all SQL editing areas in the Druid web console workbench.

Code Reference

Source Location

Signature

export function initAceDsqlMode(
  availableSqlFunctions: AvailableFunctions | undefined,
): void;

Import

import { initAceDsqlMode } from './ace-modes/dsql';

I/O Contract

Inputs

Name Type Required Description
availableSqlFunctions AvailableFunctions or undefined Yes A map of server-reported available SQL function names to include in syntax highlighting, or undefined to use only built-in functions

Outputs

Name Type Description
(side effect) void Registers 'ace/mode/dsql' and 'ace/mode/dsql_highlight_rules' modules in the Ace editor runtime

Usage Examples

Initializing the DSQL mode during bootstrap

import { initAceDsqlMode } from './ace-modes/dsql';

// Initialize with server-reported functions
initAceDsqlMode(availableFunctions);

// Then use 'dsql' as the Ace Editor mode
<AceEditor
  mode="dsql"
  theme="solarized_dark"
  value={sqlQuery}
  onChange={setSqlQuery}
/>

Related Pages

Page Connections

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