Implementation:Apache Druid SqlKeywords
| Knowledge Sources | |
|---|---|
| Domains | Web_Console, SQL_Syntax |
| Last Updated | 2026-02-10 10:00 GMT |
Overview
SqlKeywords is a module that defines the canonical lists of SQL keywords, constants, and dynamic expressions used by the Druid SQL dialect for syntax highlighting and autocompletion.
Description
The module exports three constant arrays: SQL_KEYWORDS contains 131 SQL keyword strings including standard SQL clauses (SELECT, FROM, WHERE, GROUP BY, ORDER BY), Druid-specific extensions (CLUSTERED BY, PARTITIONED BY, EXTEND), and MSQ-related keywords (INSERT INTO, REPLACE INTO, MERGE INTO). SQL_CONSTANTS contains the three SQL literal constants (NULL, FALSE, TRUE). SQL_DYNAMICS contains five dynamic timestamp expressions (CURRENT_TIMESTAMP, CURRENT_DATE, LOCALTIME, LOCALTIMESTAMP, CURRENT_TIME). Multi-word keywords are stored as single strings with spaces.
Usage
Consumed by the Druid SQL Ace mode (dsql.ts) for syntax highlighting rules, by autocompletion providers for keyword suggestions, and by SQL parsing utilities throughout the web console.
Code Reference
Source Location
- Repository: Apache Druid
- File: web-console/lib/keywords.ts
- Lines: 1-142
Signature
export const SQL_KEYWORDS: string[];
export const SQL_CONSTANTS: string[];
export const SQL_DYNAMICS: string[];
Import
import { SQL_KEYWORDS, SQL_CONSTANTS, SQL_DYNAMICS } from '../../lib/keywords';
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| (none) | This module has no inputs; it exports static constant arrays |
Outputs
| Name | Type | Description |
|---|---|---|
| SQL_KEYWORDS | string[] | 131 SQL keyword strings including multi-word keywords like 'GROUP BY' and 'INSERT INTO' |
| SQL_CONSTANTS | string[] | The three SQL literal constants: 'NULL', 'FALSE', 'TRUE' |
| SQL_DYNAMICS | string[] | Five dynamic SQL expressions: 'CURRENT_TIMESTAMP', 'CURRENT_DATE', 'LOCALTIME', 'LOCALTIMESTAMP', 'CURRENT_TIME' |
Usage Examples
Using keywords for syntax highlighting
import { SQL_KEYWORDS, SQL_CONSTANTS, SQL_DYNAMICS } from '../../lib/keywords';
// Join keywords for Ace highlight rules regex
const keywordRegex = SQL_KEYWORDS.join('|').replace(/\s/g, '|');
const constantRegex = SQL_CONSTANTS.join('|');
const dynamicRegex = SQL_DYNAMICS.join('|');