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 SegmentsView

From Leeroopedia


Knowledge Sources
Domains Web Console, Segment Management
Last Updated 2026-02-10 10:00 GMT

Overview

Renders the Segments management view in the Apache Druid web console, displaying a detailed, filterable, and paginated table of all segments in the cluster.

Description

The SegmentsView is a React class component extending PureComponent that provides a comprehensive segment inspection interface. It queries sys.segments to display per-segment details including datasource, time range, version, shard spec, partition number, size, row count, replica information, and boolean status flags (available, active, realtime, published, overshadowed). The view supports server-side sorting and filtering via SQL WHERE clauses, group-by-interval mode, an optional segment timeline visualization, and actions to view segment details or drop individual segments.

Usage

Rendered as the main content area when the user navigates to the "Segments" tab in the web console. Requires SQL or Coordinator access capability.

Code Reference

Source Location

Signature

export interface SegmentsViewProps {
  filters: TableFilters;
  onFiltersChange(filters: TableFilters): void;
  goToQuery(queryWithContext: QueryWithContext): void;
  capabilities: Capabilities;
}

export interface SegmentsViewState {
  segmentsState: QueryState<SegmentsWithAuxiliaryInfo>;
  segmentTableActionDialogId?: string;
  datasourceTableActionDialogId?: string;
  actions: BasicAction[];
  visibleColumns: LocalStorageBackedVisibility;
  groupByInterval: boolean;
  showSegmentTimeline?: { capabilities: Capabilities; datasource?: string };
  page: number;
  pageSize: number;
  sorted: SortingRule[];
  terminateSegmentId?: string;
  terminateDatasourceId?: string;
  showFullShardSpec?: string;
}

export class SegmentsView extends React.PureComponent<SegmentsViewProps, SegmentsViewState>

Import

import { SegmentsView } from '../../views/segments-view/segments-view';

I/O Contract

Inputs

Name Type Required Description
filters TableFilters Yes Current table filter state for filtering segments.
onFiltersChange (filters: TableFilters) => void Yes Callback invoked when the user changes table filters.
goToQuery (queryWithContext: QueryWithContext) => void Yes Callback to navigate to the Query view with a pre-populated query.
capabilities Capabilities Yes The detected cluster capabilities, determining which columns are available and whether SQL or API queries are used.

Outputs

Name Type Description
JSX.Element React element Renders the complete segments view including control bar, optional segment timeline, server-side paginated ReactTable, and action dialogs.

Usage Examples

Rendering the Segments View

<SegmentsView
  filters={segmentFilters}
  onFiltersChange={setSegmentFilters}
  goToQuery={handleGoToQuery}
  capabilities={capabilities}
/>

Internals

Table Columns by Mode

Mode Columns Available
full / no-proxy Segment ID, Datasource, Start, End, Version, Time span, Shard type, Shard spec, Partition, Size, Num rows, Avg. row size, Replicas, Replication factor, Is available, Is active, Is realtime, Is published, Is overshadowed
no-sql Segment ID, Datasource, Start, End, Version, Time span, Shard type, Shard spec, Partition, Size, Replication factor, Is realtime, Is overshadowed

Server-Side Query

The view constructs a SQL query against sys.segments with:

  • Dynamic column selection based on visible columns (via baseQuery static method)
  • Server-side filtering using segmentFiltersToExpression() which converts table filters to SQL WHERE clauses
  • Special handling for date columns (converting to ISO format), shard_type (searching within shard_spec JSON), and boolean columns (converting true/false to 1/0)
  • Server-side sorting via ORDER BY
  • Pagination via LIMIT and OFFSET

Filter Processing

The segmentFiltersToExpression() function provides special handling for:

  • Date columns (start, end) -- Converts filter values to ISO date strings
  • Shard type -- Converts to LIKE queries searching within the shard_spec JSON string
  • Boolean columns (is_*) -- Converts string "true"/"false" to numeric 1/0 comparisons

Dialogs

  • SegmentTableActionDialog -- Shows detailed segment information with action buttons
  • AsyncActionDialog -- Confirms segment drop operations
  • ShowValueDialog -- Displays full shard spec JSON

Segment Timeline

An optional SegmentTimeline component can be toggled via the "Timeline" button, showing a visual representation of segments over time, optionally filtered to a specific datasource.

Related Pages

Page Connections

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