= {
],
};
+function formatRangeDimensionValue(dimension: any, value: any): string {
+ return `${SqlRef.column(String(dimension))}=${SqlLiteral.create(String(value))}`;
+}
+
export interface SegmentsViewProps {
goToQuery: (initSql: string) => void;
datasource: string | undefined;
@@ -149,8 +155,9 @@ interface SegmentQueryResultRow {
version: string;
time_span: string;
partitioning: string;
- size: number;
+ shard_spec: string;
partition_num: number;
+ size: number;
num_rows: NumberLike;
avg_row_size: NumberLike;
num_replicas: number;
@@ -202,6 +209,7 @@ END AS "time_span"`,
WHEN "shard_spec" LIKE '%"type":"numbered_overwrite"%' THEN 'numbered_overwrite'
ELSE '-'
END AS "partitioning"`,
+ visibleColumns.shown('Shard detail') && `"shard_spec"`,
visibleColumns.shown('Partition') && `"partition_num"`,
visibleColumns.shown('Size') && `"size"`,
visibleColumns.shown('Num rows') && `"num_rows"`,
@@ -258,7 +266,7 @@ END AS "partitioning"`,
segmentFilter,
visibleColumns: new LocalStorageBackedVisibility(
LocalStorageKeys.SEGMENT_TABLE_COLUMN_SELECTION,
- ['Time span', 'Partitioning'],
+ ['Time span', 'Partitioning', 'Shard detail'],
),
groupByInterval: false,
showSegmentTimeline: false,
@@ -394,6 +402,7 @@ END AS "partitioning"`,
version: segment.version,
time_span: SegmentsView.computeTimeSpan(start, end),
partitioning: deepGet(segment, 'shardSpec.type') || '-',
+ shard_spec: deepGet(segment, 'shardSpec'),
partition_num: deepGet(segment, 'shardSpec.partitionNum') || 0,
size: segment.size,
num_rows: -1,
@@ -596,6 +605,67 @@ END AS "partitioning"`,
filterable: allowGeneralFilter,
Cell: renderFilterableCell('partitioning'),
},
+ {
+ Header: 'Shard detail',
+ show: visibleColumns.shown('Shard detail'),
+ accessor: 'shard_spec',
+ width: 400,
+ sortable: false,
+ filterable: false,
+ Cell: ({ value }) => {
+ let v: any;
+ try {
+ v = JSON.parse(value);
+ } catch {
+ return '-';
+ }
+
+ switch (v?.type) {
+ case 'range': {
+ const dimensions = v.dimensions || [];
+ const formatEdge = (values: string[]) =>
+ values.map((x, i) => formatRangeDimensionValue(dimensions[i], x)).join('; ');
+
+ return (
+
+ Start:
+ {Array.isArray(v.start) ? formatEdge(v.start) : '-∞'}
+
+ End:
+ {Array.isArray(v.end) ? formatEdge(v.end) : '∞'}
+
+ );
+ }
+
+ case 'single': {
+ return (
+
+ Start:
+ {v.start != null ? formatRangeDimensionValue(v.dimension, v.start) : '-∞'}
+
+ End:
+ {v.end != null ? formatRangeDimensionValue(v.dimension, v.end) : '∞'}
+
+ );
+ }
+
+ case 'hashed': {
+ const { partitionDimensions } = v;
+ if (!Array.isArray(partitionDimensions)) return value;
+ return `Partition dimensions: ${
+ partitionDimensions.length ? partitionDimensions.join('; ') : 'all'
+ }`;
+ }
+
+ case 'numbered':
+ case 'none':
+ return '-';
+
+ default:
+ return typeof value === 'string' ? value : '-';
+ }
+ },
+ },
{
Header: 'Partition',
show: visibleColumns.shown('Partition'),