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 WorkbenchHistory

From Leeroopedia
Revision as of 14:16, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/Apache_Druid_WorkbenchHistory.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


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

Overview

Concrete singleton class for managing query execution history in browser localStorage.

Description

The WorkbenchHistory class is a static singleton that manages a bounded list of WorkbenchQueryHistoryEntry objects in localStorage. It provides three core operations:

  • getHistory(): Retrieves and deserializes the history array from localStorage
  • addQueryToHistory(query): Adds a new entry if it differs from the most recent (using JSONBig comparison), then trims to MAX_ENTRIES
  • setHistory(history): Serializes and persists the history array to localStorage

The class uses json-bigint-native for comparison to correctly handle BigInt values in query results.

Usage

Call addQueryToHistory after each query execution. Call getHistory when the user opens the history dialog.

Code Reference

Source Location

  • Repository: Apache Druid
  • File: web-console/src/singletons/workbench-history.ts
  • Lines: L29-L73

Signature

export interface WorkbenchQueryHistoryEntry {
  readonly version: string;   // ISO timestamp
  readonly query: WorkbenchQuery;
}

export class WorkbenchHistory {
  static MAX_ENTRIES = 10;

  static getHistory(): WorkbenchQueryHistoryEntry[]
  static addQueryToHistory(query: WorkbenchQuery): void

  private static getHistoryVersion(): string
  private static setHistory(history: WorkbenchQueryHistoryEntry[]): void
}

Import

import { WorkbenchHistory } from '../../singletons/workbench-history';

I/O Contract

Inputs

Name Type Required Description
query WorkbenchQuery Yes Query to add to history (for addQueryToHistory)

Outputs

Name Type Description
history WorkbenchQueryHistoryEntry[] Array of up to 10 recent queries with timestamps

Usage Examples

Recording and Retrieving History

import { WorkbenchHistory } from '../../singletons/workbench-history';

// After query execution:
WorkbenchHistory.addQueryToHistory(executedQuery);

// In history dialog:
const history = WorkbenchHistory.getHistory();
// history = [
//   { version: '2024-01-15 10:30:00', query: WorkbenchQuery({ queryString: 'SELECT ...' }) },
//   { version: '2024-01-15 10:25:00', query: WorkbenchQuery({ queryString: 'SELECT ...' }) },
// ]

// Re-execute a historical query:
const oldQuery = history[2].query;
setCurrentQuery(oldQuery);

Related Pages

Implements Principle

Requires Environment

Page Connections

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