Skip to content

Commit 338a35e

Browse files
authored
Web console: workbench query should remain attached (#18776)
* workbench query should remain attached * protective coding around future dates * Filter segment timeline to for digit years only * update deps to fix bugs
1 parent b3be269 commit 338a35e

File tree

6 files changed

+40
-24
lines changed

6 files changed

+40
-24
lines changed

licenses.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5550,7 +5550,7 @@ license_category: binary
55505550
module: web-console
55515551
license_name: Apache License version 2.0
55525552
copyright: Vadim Ogievetsky
5553-
version: 1.2.1
5553+
version: 1.2.3
55545554

55555555
---
55565556

@@ -5848,7 +5848,7 @@ license_category: binary
58485848
module: web-console
58495849
license_name: Apache License version 2.0
58505850
copyright: Imply Data
5851-
version: 1.2.1
5851+
version: 1.2.2
58525852

58535853
---
58545854

web-console/package-lock.json

Lines changed: 14 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

web-console/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
"@internationalized/date": "^3.5.6",
6262
"ace-builds": "~1.5.3",
6363
"axios": "^1.12.0",
64-
"chronoshift": "^1.2.1",
64+
"chronoshift": "^1.2.3",
6565
"classnames": "^2.2.6",
6666
"copy-to-clipboard": "^3.3.3",
6767
"d3-array": "^3.2.4",
@@ -73,7 +73,7 @@
7373
"d3-time-format": "^4.1.0",
7474
"date-fns": "^2.28.0",
7575
"dayjs": "^1.11.15",
76-
"druid-query-toolkit": "^1.2.1",
76+
"druid-query-toolkit": "^1.2.2",
7777
"echarts": "^5.5.1",
7878
"file-saver": "^2.0.5",
7979
"hjson": "^3.2.2",

web-console/src/components/segment-timeline/segment-timeline.tsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ import { day, Duration, Timezone } from 'chronoshift';
3434
import { C, L, N, SqlExpression, SqlQuery } from 'druid-query-toolkit';
3535
import { useEffect, useMemo, useState } from 'react';
3636

37-
import { END_OF_TIME_DATE, START_OF_TIME_DATE } from '../../druid-models';
3837
import type { Capabilities } from '../../helpers';
3938
import { useQueryManager } from '../../hooks';
4039
import {
@@ -56,6 +55,7 @@ import { SegmentBarChart } from './segment-bar-chart';
5655

5756
import './segment-timeline.scss';
5857

58+
const FOUR_DIGIT_YEAR_LIKE = '____-%';
5959
const DEFAULT_SHOWN_DURATION = new Duration('P1Y');
6060
const SHOWN_DURATION_OPTIONS: Duration[] = ['P1D', 'P1W', 'P1M', 'P3M', 'P1Y', 'P5Y', 'P10Y'].map(
6161
d => new Duration(d),
@@ -122,8 +122,8 @@ export const SegmentTimeline = function SegmentTimeline(props: SegmentTimelinePr
122122
const baseQuery = SqlQuery.from(N('sys').table('segments'))
123123
.changeWhereExpression(
124124
SqlExpression.and(
125-
C('start').unequal(START_OF_TIME_DATE),
126-
C('end').unequal(END_OF_TIME_DATE),
125+
C('start').like(FOUR_DIGIT_YEAR_LIKE),
126+
C('end').like(FOUR_DIGIT_YEAR_LIKE),
127127
C('is_overshadowed').equal(0),
128128
datasource ? C('datasource').equal(L(datasource)) : undefined,
129129
),
@@ -141,7 +141,12 @@ export const SegmentTimeline = function SegmentTimeline(props: SegmentTimelinePr
141141
return getDateRange(DEFAULT_SHOWN_DURATION);
142142
}
143143

144-
queriedEnd = day.ceil(new Date(endRes[0].end), Timezone.UTC);
144+
const endResDate = new Date(endRes[0].end); // Need to be protective against a date in the far future
145+
if (isNaN(endResDate.valueOf())) {
146+
return getDateRange(DEFAULT_SHOWN_DURATION);
147+
}
148+
149+
queriedEnd = day.ceil(endResDate, Timezone.UTC);
145150

146151
const startQuery = baseQuery
147152
.addSelect(C('start'), { addToOrderBy: 'end', direction: 'ASC' })

web-console/src/druid-models/workbench-query/workbench-query.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ export class WorkbenchQuery {
230230
public readonly unlimited?: boolean;
231231
public readonly prefixLines?: number;
232232

233-
public readonly parsedQuery?: SqlQuery;
233+
public readonly parsedQuery?: SqlQuery; // Derived from query string
234234

235235
constructor(value: WorkbenchQueryValue) {
236236
let queryString = value.queryString;
@@ -267,7 +267,9 @@ export class WorkbenchQuery {
267267
queryContext: this.queryContext,
268268
queryParameters: this.queryParameters,
269269
engine: this.engine,
270+
lastExecution: this.lastExecution,
270271
unlimited: this.unlimited,
272+
prefixLines: this.prefixLines,
271273
};
272274
}
273275

@@ -281,6 +283,12 @@ export class WorkbenchQuery {
281283
].join('\n\n');
282284
}
283285

286+
public formatLastExecution(): string | undefined {
287+
const { lastExecution } = this;
288+
if (!lastExecution) return;
289+
return `Attached to: ${lastExecution.id} (${lastExecution.engine})`;
290+
}
291+
284292
public changeQueryString(queryString: string): WorkbenchQuery {
285293
return new WorkbenchQuery({ ...this.valueOf(), queryString });
286294
}

web-console/src/views/workbench-view/workbench-view.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ import { ExecutionStateCache } from '../../singletons/execution-state-cache';
5757
import { WorkbenchRunningPromises } from '../../singletons/workbench-running-promises';
5858
import type { ColumnMetadata } from '../../utils';
5959
import {
60+
assemble,
6061
deepSet,
6162
generate8HexId,
6263
localStorageGet,
@@ -552,7 +553,9 @@ export class WorkbenchView extends React.PureComponent<WorkbenchViewProps, Workb
552553
<div
553554
key={i}
554555
className={classNames('tab-button', { active })}
555-
data-tooltip={tabEntry.tabName}
556+
data-tooltip={assemble(tabEntry.tabName, tabEntry.query.formatLastExecution()).join(
557+
'\n',
558+
)}
556559
>
557560
{active ? (
558561
<Popover

0 commit comments

Comments
 (0)