@akohn/dashql-react 0.0.20-dev.675.gf906d82d4 → 0.0.20-dev.872.ge142320b5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/NOTICE +53 -1
- package/README.md +5 -3
- package/dist/components/data_table/data_table.d.ts +0 -1
- package/dist/components/data_table/data_table.js +4 -9
- package/dist/components/data_table/data_table_cell_header_plots.d.ts +1 -3
- package/dist/components/data_table/data_table_cell_header_plots.js +4 -6
- package/dist/components/data_table/histogram_brush.d.ts +0 -1
- package/dist/components/data_table/histogram_brush.js +3 -5
- package/dist/components/data_table/histogram_cell.d.ts +0 -2
- package/dist/components/data_table/histogram_cell.js +1 -2
- package/dist/components/name_input.d.ts +1 -0
- package/dist/components/name_input.js +13 -1
- package/dist/components/query_history_viewer.d.ts +1 -3
- package/dist/components/query_history_viewer.js +7 -4
- package/dist/components/query_profile/profile_execution_controller.d.ts +0 -2
- package/dist/components/query_profile/profile_execution_controller.js +0 -12
- package/dist/components/query_profile/query_profile_view.d.ts +1 -9
- package/dist/components/query_profile/query_profile_view.js +19 -27
- package/dist/components/vegalite_chart.d.ts +0 -2
- package/dist/components/vegalite_chart.js +1 -3
- package/dist/components/vegalite_view.d.ts +0 -1
- package/dist/components/vegalite_view.js +9 -18
- package/dist/components/visualization/vegalite_preview.d.ts +1 -1
- package/dist/components/visualization/visualization_dispatch.d.ts +0 -1
- package/dist/components/visualization/visualization_dispatch.js +0 -1
- package/dist/components/visualization/visualization_panel.d.ts +1 -1
- package/dist/components/visualization/visualization_panel.js +0 -1
- package/dist/hooks.d.ts +2 -1
- package/dist/hooks.js +4 -1
- package/dist/logger.d.ts +2 -2
- package/dist/logger.js +8 -1
- package/dist/models/script_model.js +4 -14
- package/dist/platform/embedded_database_provider.d.ts +1 -1
- package/dist/platform/page_runtime.d.ts +1 -1
- package/dist/vegalite/vegalite_image.d.ts +0 -2
- package/dist/vegalite/vegalite_image.js +1 -1
- package/package.json +372 -16
package/NOTICE
CHANGED
|
@@ -9,7 +9,7 @@ their own licenses.
|
|
|
9
9
|
1. GitHub Octicons
|
|
10
10
|
--------------------------------------------------------------------------------
|
|
11
11
|
|
|
12
|
-
Icon geometry under `packages/dashql-
|
|
12
|
+
Icon geometry under `packages/dashql-react/svg/icons/` includes icons from
|
|
13
13
|
GitHub Octicons (https://github.com/primer/octicons).
|
|
14
14
|
|
|
15
15
|
MIT License
|
|
@@ -64,3 +64,55 @@ and used here under the MIT license.
|
|
|
64
64
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
65
65
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
66
66
|
SOFTWARE.
|
|
67
|
+
|
|
68
|
+
--------------------------------------------------------------------------------
|
|
69
|
+
3. Instrument Sans and JetBrains Mono
|
|
70
|
+
--------------------------------------------------------------------------------
|
|
71
|
+
|
|
72
|
+
The fonts under `packages/dashql-react/fonts/` are Instrument Sans
|
|
73
|
+
(https://github.com/Instrument/instrument-sans, Copyright 2022 The Instrument
|
|
74
|
+
Sans Project Authors) and JetBrains Mono
|
|
75
|
+
(https://github.com/JetBrains/JetBrainsMono, Copyright 2020 The JetBrains Mono
|
|
76
|
+
Project Authors), both under the SIL Open Font License, Version 1.1. The full
|
|
77
|
+
license text ships next to the fonts in `InstrumentSans-OFL.txt` and
|
|
78
|
+
`JetBrainsMono-OFL.txt`.
|
|
79
|
+
|
|
80
|
+
--------------------------------------------------------------------------------
|
|
81
|
+
4. Google protocol buffers
|
|
82
|
+
--------------------------------------------------------------------------------
|
|
83
|
+
|
|
84
|
+
`proto/pb/google/rpc/status.proto` is a copy of google/rpc/status.proto
|
|
85
|
+
(https://github.com/googleapis/googleapis), Copyright 2020 Google LLC, licensed
|
|
86
|
+
under the Apache License, Version 2.0
|
|
87
|
+
(http://www.apache.org/licenses/LICENSE-2.0).
|
|
88
|
+
|
|
89
|
+
`proto/pb/google/protobuf/{any,empty,timestamp}.proto` are copies of the
|
|
90
|
+
well-known types of Protocol Buffers (https://github.com/protocolbuffers/protobuf).
|
|
91
|
+
|
|
92
|
+
Copyright 2008 Google Inc. All rights reserved.
|
|
93
|
+
|
|
94
|
+
Redistribution and use in source and binary forms, with or without
|
|
95
|
+
modification, are permitted provided that the following conditions are
|
|
96
|
+
met:
|
|
97
|
+
|
|
98
|
+
* Redistributions of source code must retain the above copyright
|
|
99
|
+
notice, this list of conditions and the following disclaimer.
|
|
100
|
+
* Redistributions in binary form must reproduce the above
|
|
101
|
+
copyright notice, this list of conditions and the following disclaimer
|
|
102
|
+
in the documentation and/or other materials provided with the
|
|
103
|
+
distribution.
|
|
104
|
+
* Neither the name of Google Inc. nor the names of its
|
|
105
|
+
contributors may be used to endorse or promote products derived from
|
|
106
|
+
this software without specific prior written permission.
|
|
107
|
+
|
|
108
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
109
|
+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
110
|
+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
111
|
+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
112
|
+
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
113
|
+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
114
|
+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
115
|
+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
116
|
+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
117
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
118
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
package/README.md
CHANGED
|
@@ -13,7 +13,8 @@ come from the same build. The Vega libraries are optional peers, for the charts.
|
|
|
13
13
|
|
|
14
14
|
## Using it
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
Every public module is a subpath of its own, at the path of its source. The `exports` of the package list them, the
|
|
17
|
+
other modules stay inside it:
|
|
17
18
|
|
|
18
19
|
```tsx
|
|
19
20
|
import '@akohn/dashql-react/style.css';
|
|
@@ -57,7 +58,7 @@ import { openPageStorage } from '@akohn/dashql/platform/storage/page_storage';
|
|
|
57
58
|
import { createWorkbookResultFiles } from '@akohn/dashql/platform/workbook/workbook_result_files';
|
|
58
59
|
import { WebHttpClient } from '@akohn/dashql/platform/web_http_client';
|
|
59
60
|
import { createEmbeddedChannelConnector } from '@akohn/dashql/runtime/embedded_channels';
|
|
60
|
-
import { createRuntime } from '@akohn/dashql/runtime
|
|
61
|
+
import { createRuntime } from '@akohn/dashql/runtime';
|
|
61
62
|
import { FRAME_UPDATE_SCHEDULER } from '@akohn/dashql/runtime/store/update_scheduler';
|
|
62
63
|
import { createRuntimeArchives } from '@akohn/dashql/runtime/workbook_archives';
|
|
63
64
|
import { RuntimeContextProvider } from '@akohn/dashql-react/hooks';
|
|
@@ -97,7 +98,8 @@ function Console() {
|
|
|
97
98
|
}
|
|
98
99
|
|
|
99
100
|
function ConsoleRuntime(props: { core: DashQL; storage: StorageBackend }) {
|
|
100
|
-
|
|
101
|
+
// Null only outside of an EmbeddedDatabaseProvider
|
|
102
|
+
const database = useEmbeddedDatabaseSetup()!;
|
|
101
103
|
const runtime = usePageRuntime(() => createRuntime({
|
|
102
104
|
logger,
|
|
103
105
|
scheduler: FRAME_UPDATE_SCHEDULER,
|
|
@@ -30,7 +30,6 @@ var COLUMN_HEADER_PLOTS_COLLAPSED_HEIGHT = 18;
|
|
|
30
30
|
var ROW_HEIGHT = 26;
|
|
31
31
|
var MORE_ROWS_HEIGHT = 24;
|
|
32
32
|
var GRID_OVERSCAN_COUNT = 10;
|
|
33
|
-
var NOOP_BRUSHING = () => {};
|
|
34
33
|
function computeGridHeight(baseRowCount, visibleRowCount, headerHeight, scrollbarHeight, fitHeight, maxHeight, measuredHeight = 0, maxRows) {
|
|
35
34
|
const contentHeight = headerHeight + visibleRowCount * 26 + scrollbarHeight;
|
|
36
35
|
if (fitHeight) return Math.min(headerHeight + (maxRows == null ? baseRowCount : Math.min(baseRowCount, maxRows)) * 26 + scrollbarHeight, maxHeight ?? Number.POSITIVE_INFINITY);
|
|
@@ -44,7 +43,8 @@ var DataTable = React.memo((props) => {
|
|
|
44
43
|
if (tables.dataTable == null) return null;
|
|
45
44
|
return /* @__PURE__ */ jsx(DataTableGrid, {
|
|
46
45
|
...props,
|
|
47
|
-
dataTable: tables.dataTable
|
|
46
|
+
dataTable: tables.dataTable,
|
|
47
|
+
matchingRows: tables.matchingRows
|
|
48
48
|
});
|
|
49
49
|
});
|
|
50
50
|
function DataTableGrid(props) {
|
|
@@ -53,7 +53,7 @@ function DataTableGrid(props) {
|
|
|
53
53
|
const summaryTables = props.model.tables;
|
|
54
54
|
const dispatchComputation = props.model.dispatch;
|
|
55
55
|
const dataTable = props.dataTable;
|
|
56
|
-
const matchingRows =
|
|
56
|
+
const matchingRows = props.matchingRows;
|
|
57
57
|
const { tableAggregation, columnAggregates, filteredColumnAggregates, columnGroups } = computationState;
|
|
58
58
|
const dataTableHandle = computationState.dataTable;
|
|
59
59
|
const summaries = React.useMemo(() => resolveSummaries({
|
|
@@ -231,11 +231,9 @@ function DataTableGrid(props) {
|
|
|
231
231
|
selectionEpoch,
|
|
232
232
|
dataSearchRequestId,
|
|
233
233
|
crossFilters,
|
|
234
|
-
isVisible: true,
|
|
235
234
|
rightmostVisibleColumn: gridLayout.columnCount - 1,
|
|
236
235
|
onRequestFilteredColumnAggregation: requestFilteredColumnAggregation,
|
|
237
236
|
onHistogramFilter: histogramFilter,
|
|
238
|
-
onBrushingChange: NOOP_BRUSHING,
|
|
239
237
|
onMostFrequentValueFilter: mostFrequentValueFilter
|
|
240
238
|
}), [
|
|
241
239
|
gridLayout,
|
|
@@ -260,10 +258,7 @@ function DataTableGrid(props) {
|
|
|
260
258
|
[root_more_rows]: hasFooterRow
|
|
261
259
|
}),
|
|
262
260
|
"data-electron-drag-region": "false",
|
|
263
|
-
style: {
|
|
264
|
-
...props.cellBackground ? { "--data_table_bg": props.cellBackground } : {},
|
|
265
|
-
...props.fitHeight ? { height: gridContainerHeight + footerRowCount * 23 } : {}
|
|
266
|
-
},
|
|
261
|
+
style: { ...props.fitHeight ? { height: gridContainerHeight + footerRowCount * 23 } : {} },
|
|
267
262
|
children: [
|
|
268
263
|
/* @__PURE__ */ jsxs("div", {
|
|
269
264
|
className: grid_container,
|
|
@@ -2,7 +2,7 @@ import * as React from 'react';
|
|
|
2
2
|
import type * as core from '@akohn/dashql';
|
|
3
3
|
import type { ComputationColumnGroup, ComputationTrackedTask, ComputationVersionValue } from '@akohn/dashql';
|
|
4
4
|
import { ColumnAggregationVariant, TableAggregation, WithFilterEpoch } from '@akohn/dashql/platform/compute/computation_types';
|
|
5
|
-
import {
|
|
5
|
+
import { HistogramFilterCallback } from './histogram_cell.js';
|
|
6
6
|
import { MostFrequentValueFilterCallback } from './mostfrequent_cell.js';
|
|
7
7
|
import { DataTableLayout } from './data_table_layout.js';
|
|
8
8
|
export interface HeaderPlotsCellProps {
|
|
@@ -19,11 +19,9 @@ export interface HeaderPlotsCellProps {
|
|
|
19
19
|
selectionEpoch: ComputationVersionValue;
|
|
20
20
|
dataSearchRequestId: number | null;
|
|
21
21
|
crossFilters: core.ComputationCrossFilter[];
|
|
22
|
-
isVisible: boolean;
|
|
23
22
|
rightmostVisibleColumn: number;
|
|
24
23
|
onRequestFilteredColumnAggregation: (columnId: number) => void;
|
|
25
24
|
onHistogramFilter: HistogramFilterCallback;
|
|
26
|
-
onBrushingChange: BrushingStateCallback;
|
|
27
25
|
onMostFrequentValueFilter: MostFrequentValueFilterCallback;
|
|
28
26
|
}
|
|
29
27
|
declare function HeaderPlotsCellImpl(props: HeaderPlotsCellProps): React.ReactElement;
|
|
@@ -23,9 +23,9 @@ function HeaderPlotsCellImpl(props) {
|
|
|
23
23
|
filteredColumnAggregationTask = props.filteredColumnAggregationTasks[columnAggregateId] ?? null;
|
|
24
24
|
filteredColumnAggregationOutdated = props.filteredColumnAggregationOutdated[columnAggregateId] ?? false;
|
|
25
25
|
}
|
|
26
|
-
const {
|
|
26
|
+
const { onRequestFilteredColumnAggregation } = props;
|
|
27
27
|
React.useEffect(() => {
|
|
28
|
-
if (columnAggregateId == -1 || !
|
|
28
|
+
if (columnAggregateId == -1 || !filteredColumnAggregationOutdated) return;
|
|
29
29
|
onRequestFilteredColumnAggregation(columnAggregateId);
|
|
30
30
|
}, [
|
|
31
31
|
columnAggregateId,
|
|
@@ -33,11 +33,10 @@ function HeaderPlotsCellImpl(props) {
|
|
|
33
33
|
filteredColumnAggregationTask,
|
|
34
34
|
props.selectionEpoch,
|
|
35
35
|
props.dataSearchRequestId,
|
|
36
|
-
isVisible,
|
|
37
36
|
onRequestFilteredColumnAggregation
|
|
38
37
|
]);
|
|
39
38
|
const isRightmost = props.columnIndex === props.rightmostVisibleColumn;
|
|
40
|
-
if (pastFields
|
|
39
|
+
if (pastFields) return /* @__PURE__ */ jsx("div", { style: props.style });
|
|
41
40
|
const columnGroupId = props.gridLayout.columnGroupByColumnIndex[props.columnIndex];
|
|
42
41
|
const columnGroup = props.columnGroups[columnGroupId];
|
|
43
42
|
const crossFilter = crossFilterOf(props.crossFilters, columnGroupId);
|
|
@@ -96,8 +95,7 @@ function HeaderPlotsCellImpl(props) {
|
|
|
96
95
|
columnIndex: props.columnIndex,
|
|
97
96
|
columnAggregate: columnAggregate.value,
|
|
98
97
|
selection: histogramSelection,
|
|
99
|
-
onFilter: props.onHistogramFilter
|
|
100
|
-
onBrushingChange: props.onBrushingChange
|
|
98
|
+
onFilter: props.onHistogramFilter
|
|
101
99
|
});
|
|
102
100
|
case STRING_COLUMN: return /* @__PURE__ */ jsx(MostFrequentCell, {
|
|
103
101
|
className: classNames(plots_cell, { [plots_cell_rightmost]: isRightmost }),
|
|
@@ -14,7 +14,6 @@ interface HistogramBrushOptions {
|
|
|
14
14
|
selection: [number, number] | null;
|
|
15
15
|
onBrushUpdate: (event: d3.D3BrushEvent<unknown>) => void;
|
|
16
16
|
onClear: () => void;
|
|
17
|
-
onBrushingChange?: (isBrushing: boolean) => void;
|
|
18
17
|
}
|
|
19
18
|
export declare function useHistogramBrush(options: HistogramBrushOptions): {
|
|
20
19
|
brushContainer: React.RefObject<SVGGElement | null>;
|
|
@@ -34,7 +34,7 @@ function useHistogramBrush(options) {
|
|
|
34
34
|
const brushBehavior = React.useRef(null);
|
|
35
35
|
const syncingSelection = React.useRef(false);
|
|
36
36
|
const settledBrushUpdates = React.useRef(new SettledBrushUpdates());
|
|
37
|
-
const { xScale, height, selection, onBrushUpdate, onClear
|
|
37
|
+
const { xScale, height, selection, onBrushUpdate, onClear } = options;
|
|
38
38
|
const onBrushUpdateRef = React.useRef(onBrushUpdate);
|
|
39
39
|
onBrushUpdateRef.current = onBrushUpdate;
|
|
40
40
|
const selectionRef = React.useRef(selection);
|
|
@@ -42,8 +42,7 @@ function useHistogramBrush(options) {
|
|
|
42
42
|
const onBrushStart = React.useCallback(() => {
|
|
43
43
|
if (syncingSelection.current) return;
|
|
44
44
|
settledBrushUpdates.current.cancel();
|
|
45
|
-
|
|
46
|
-
}, [onBrushingChange]);
|
|
45
|
+
}, []);
|
|
47
46
|
const onBrushMove = React.useCallback((event) => {
|
|
48
47
|
if (syncingSelection.current) return;
|
|
49
48
|
settledBrushUpdates.current.schedule(event, (pending) => onBrushUpdateRef.current(pending));
|
|
@@ -51,8 +50,7 @@ function useHistogramBrush(options) {
|
|
|
51
50
|
const onBrushEnd = React.useCallback((event) => {
|
|
52
51
|
if (syncingSelection.current) return;
|
|
53
52
|
settledBrushUpdates.current.flush(event, onBrushUpdate);
|
|
54
|
-
|
|
55
|
-
}, [onBrushUpdate, onBrushingChange]);
|
|
53
|
+
}, [onBrushUpdate]);
|
|
56
54
|
const onBrushStartRef = React.useRef(onBrushStart);
|
|
57
55
|
const onBrushMoveRef = React.useRef(onBrushMove);
|
|
58
56
|
const onBrushEndRef = React.useRef(onBrushEnd);
|
|
@@ -3,7 +3,6 @@ import { ColumnAggregationVariant, OrdinalColumnAggregation, TableAggregation, W
|
|
|
3
3
|
export { NULL_SYMBOL } from './histogram_bars.js';
|
|
4
4
|
export { SettledBrushUpdates } from './histogram_brush.js';
|
|
5
5
|
export type HistogramFilterCallback = (table: TableAggregation, columnId: number, column: OrdinalColumnAggregation, filter: [number, number] | null) => void;
|
|
6
|
-
export type BrushingStateCallback = (isBrushing: boolean) => void;
|
|
7
6
|
interface HistogramCellProps {
|
|
8
7
|
className?: string;
|
|
9
8
|
style?: React.CSSProperties;
|
|
@@ -13,7 +12,6 @@ interface HistogramCellProps {
|
|
|
13
12
|
filteredColumnAggregation: WithFilterEpoch<ColumnAggregationVariant> | null;
|
|
14
13
|
selection: [number, number] | null;
|
|
15
14
|
onFilter: HistogramFilterCallback;
|
|
16
|
-
onBrushingChange?: BrushingStateCallback;
|
|
17
15
|
}
|
|
18
16
|
declare function HistogramCellImpl(props: HistogramCellProps): React.ReactElement;
|
|
19
17
|
export declare const HistogramCell: React.MemoExoticComponent<typeof HistogramCellImpl>;
|
|
@@ -93,8 +93,7 @@ function HistogramCellImpl(props) {
|
|
|
93
93
|
height,
|
|
94
94
|
selection: brushSelection,
|
|
95
95
|
onBrushUpdate,
|
|
96
|
-
onClear: clearFilter
|
|
97
|
-
onBrushingChange: props.onBrushingChange
|
|
96
|
+
onClear: clearFilter
|
|
98
97
|
});
|
|
99
98
|
const nullsPadding = (nullsWidth - nullsXScale.bandwidth()) / 2;
|
|
100
99
|
const hasFilteredAggregate = props.filteredColumnAggregation != null && props.filteredColumnAggregation.type === ORDINAL_COLUMN;
|
|
@@ -3,8 +3,20 @@ import { jsx } from "react/jsx-runtime";
|
|
|
3
3
|
var NameInput = React.forwardRef((props, forwardedRef) => {
|
|
4
4
|
const inputRef = React.useRef(null);
|
|
5
5
|
const skipBlurCommitRef = React.useRef(false);
|
|
6
|
-
const { name, onCommit, onCancel } = props;
|
|
6
|
+
const { name, onCommit, onCancel, autoSelect } = props;
|
|
7
7
|
React.useImperativeHandle(forwardedRef, () => inputRef.current, []);
|
|
8
|
+
React.useEffect(() => {
|
|
9
|
+
if (!autoSelect) return;
|
|
10
|
+
const select = () => {
|
|
11
|
+
inputRef.current?.focus();
|
|
12
|
+
inputRef.current?.select();
|
|
13
|
+
};
|
|
14
|
+
select();
|
|
15
|
+
const frame = requestAnimationFrame(() => {
|
|
16
|
+
if (document.activeElement !== inputRef.current) select();
|
|
17
|
+
});
|
|
18
|
+
return () => cancelAnimationFrame(frame);
|
|
19
|
+
}, [autoSelect]);
|
|
8
20
|
React.useEffect(() => {
|
|
9
21
|
if (inputRef.current != null) inputRef.current.value = name ?? "";
|
|
10
22
|
}, [name]);
|
|
@@ -8,11 +8,9 @@ export declare enum QueryTarget {
|
|
|
8
8
|
MEMORY = "Memory"
|
|
9
9
|
}
|
|
10
10
|
export declare function getQueryTarget(query: QueryExecutionState): QueryTarget;
|
|
11
|
+
export declare function getQuerySourceName(query: QueryExecutionState, connectorName: string): string;
|
|
11
12
|
export interface QueryEntry {
|
|
12
|
-
connectionId: string;
|
|
13
13
|
sourceName: string;
|
|
14
|
-
target: QueryTarget;
|
|
15
|
-
queryId: number;
|
|
16
14
|
query: QueryExecutionState;
|
|
17
15
|
}
|
|
18
16
|
interface QueryRowProps {
|
|
@@ -11,7 +11,7 @@ import { VerticalScrollShadows } from "./vertical_scroll_shadows.js";
|
|
|
11
11
|
import { InspectorDetail, InspectorEmpty, InspectorOverlay, inspectorRowClassName } from "./inspector_overlay.js";
|
|
12
12
|
import * as React from "react";
|
|
13
13
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
14
|
-
import { QueryExecutionStatus } from "@akohn/dashql/platform/query/query_execution_state";
|
|
14
|
+
import { QueryExecutionStatus, QueryType } from "@akohn/dashql/platform/query/query_execution_state";
|
|
15
15
|
import { List, useListCallbackRef } from "react-window";
|
|
16
16
|
var ROW_HEIGHT = 32;
|
|
17
17
|
var QueryTarget = /* @__PURE__ */ function(QueryTarget) {
|
|
@@ -22,6 +22,9 @@ var QueryTarget = /* @__PURE__ */ function(QueryTarget) {
|
|
|
22
22
|
function getQueryTarget(query) {
|
|
23
23
|
return query.queryMetadata.userProvided ? QueryTarget.CONNECTION : QueryTarget.MEMORY;
|
|
24
24
|
}
|
|
25
|
+
function getQuerySourceName(query, connectorName) {
|
|
26
|
+
return query.queryMetadata.queryType == QueryType.INTERNAL_SQLFRAME ? "SQLFrame" : connectorName;
|
|
27
|
+
}
|
|
25
28
|
function getStatusLabel(status) {
|
|
26
29
|
switch (status) {
|
|
27
30
|
case QueryExecutionStatus.REQUESTED: return "requested";
|
|
@@ -45,7 +48,7 @@ function entryToObject(entry) {
|
|
|
45
48
|
traceId: q.traceId,
|
|
46
49
|
status: QueryExecutionStatus[q.status],
|
|
47
50
|
source: entry.sourceName,
|
|
48
|
-
target: entry.
|
|
51
|
+
target: getQueryTarget(entry.query),
|
|
49
52
|
queryText: q.queryText,
|
|
50
53
|
metadata: q.queryMetadata,
|
|
51
54
|
metrics: {
|
|
@@ -91,7 +94,7 @@ var QueryRow = (props) => {
|
|
|
91
94
|
}),
|
|
92
95
|
/* @__PURE__ */ jsx("div", {
|
|
93
96
|
className: query_cell,
|
|
94
|
-
children: entry.
|
|
97
|
+
children: getQueryTarget(entry.query)
|
|
95
98
|
}),
|
|
96
99
|
/* @__PURE__ */ jsx("div", {
|
|
97
100
|
className: query_cell_status,
|
|
@@ -265,4 +268,4 @@ function QueryHistoryViewer(props) {
|
|
|
265
268
|
})
|
|
266
269
|
})] });
|
|
267
270
|
}
|
|
268
|
-
export { QueryHistoryViewer, QueryRow, QueryTarget, ROW_HEIGHT, getQueryTarget };
|
|
271
|
+
export { QueryHistoryViewer, QueryRow, QueryTarget, ROW_HEIGHT, getQuerySourceName, getQueryTarget };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import * as dashql from '@akohn/dashql';
|
|
2
1
|
import type { ProfileExecutionState } from '@akohn/dashql/platform/query/profile_execution_state';
|
|
3
2
|
export declare class ProfileExecutionController {
|
|
4
3
|
private operatorElements;
|
|
@@ -9,6 +8,5 @@ export declare class ProfileExecutionController {
|
|
|
9
8
|
registerPipeline(id: number, path: SVGPathElement | null): void;
|
|
10
9
|
private setOperatorStatus;
|
|
11
10
|
private setPipelineStatus;
|
|
12
|
-
applyEvents(events: dashql.buffers.profile.QueryProfileEvents): void;
|
|
13
11
|
applyState(state: ProfileExecutionState, operatorFragments?: readonly number[]): void;
|
|
14
12
|
}
|
|
@@ -28,18 +28,6 @@ var ProfileExecutionController = class {
|
|
|
28
28
|
const path = this.pipelinePaths[id];
|
|
29
29
|
if (path != null) path.dataset.status = `${status}`;
|
|
30
30
|
}
|
|
31
|
-
applyEvents(events) {
|
|
32
|
-
const event = new view.ProfileUpdateEvent();
|
|
33
|
-
for (let i = 0; i < events.eventsLength(); ++i) {
|
|
34
|
-
events.events(i, event);
|
|
35
|
-
switch (event.entity()) {
|
|
36
|
-
case view.ProfileEntity.OPERATOR:
|
|
37
|
-
this.setOperatorStatus(event.index(), event.status());
|
|
38
|
-
break;
|
|
39
|
-
case view.ProfileEntity.PIPELINE: this.setPipelineStatus(event.index(), event.status());
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
31
|
applyState(state, operatorFragments = []) {
|
|
44
32
|
for (let id = 0; id < this.statuses.length; ++id) {
|
|
45
33
|
const own = state.operators[id]?.status ?? view.ProfileExecutionStatus.UNKNOWN;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import * as dashql from '@akohn/dashql';
|
|
3
3
|
import { createProfileLayoutConfig } from '@akohn/dashql/platform/query/profile_layout_config';
|
|
4
|
-
import { ProfileExecutionController } from './profile_execution_controller.js';
|
|
5
4
|
import { ProfileExecutionState, type ProfileEntityState } from '@akohn/dashql/platform/query/profile_execution_state';
|
|
6
5
|
import { materializeProfileScene, ProfileSceneOperator } from './profile_scene.js';
|
|
7
6
|
export { materializeProfileScene, PROFILE_OPERATOR_PORT_INPUT, PROFILE_OPERATOR_PORT_OUTPUT, type ProfileScene, type ProfileSceneOperator, } from './profile_scene.js';
|
|
@@ -15,10 +14,8 @@ export interface QueryProfileViewProps {
|
|
|
15
14
|
plan: dashql.FlatBufferPtr<dashql.buffers.profile.QueryProfile>;
|
|
16
15
|
execution?: ProfileExecutionState;
|
|
17
16
|
showProgress?: boolean;
|
|
18
|
-
controllerRef?: React.RefObject<ProfileExecutionController | null>;
|
|
19
17
|
autoFocus?: boolean;
|
|
20
18
|
fill?: boolean;
|
|
21
|
-
edgeRendering?: ProfileEdgeRenderingConfig;
|
|
22
19
|
onRotate?: () => void;
|
|
23
20
|
dependencies?: QueryProfileViewDependencies;
|
|
24
21
|
}
|
|
@@ -29,11 +26,6 @@ export type ProfileEdgeColorScheme = (value: number) => string;
|
|
|
29
26
|
export declare const PROFILE_EDGE_COLOR_SCHEME_RD_BU: ProfileEdgeColorScheme;
|
|
30
27
|
export declare const PROFILE_EDGE_COLOR_SCHEME_RD_PU: ProfileEdgeColorScheme;
|
|
31
28
|
export declare const PROFILE_COST_COLOR_SCHEME_OR_RD: ProfileEdgeColorScheme;
|
|
32
|
-
export interface ProfileEdgeRenderingConfig {
|
|
33
|
-
colorScheme?: ProfileEdgeColorScheme;
|
|
34
|
-
rowColorScheme?: ProfileEdgeColorScheme;
|
|
35
|
-
costColorScheme?: ProfileEdgeColorScheme;
|
|
36
|
-
}
|
|
37
29
|
export declare function formatEstimateSymbol(difference: number, absoluteDifference?: number): string;
|
|
38
30
|
export declare function formatCpuShare(share: number): string;
|
|
39
31
|
export declare function formatShortBytes(bytes: number): string;
|
|
@@ -41,4 +33,4 @@ export declare function placeOperatorAnnotation(operator: Pick<ProfileSceneOpera
|
|
|
41
33
|
x: number;
|
|
42
34
|
y: number;
|
|
43
35
|
};
|
|
44
|
-
export declare function QueryProfileView({ plan, execution, showProgress,
|
|
36
|
+
export declare function QueryProfileView({ plan, execution, showProgress, autoFocus, fill, onRotate, dependencies }: QueryProfileViewProps): React.JSX.Element;
|
|
@@ -220,6 +220,13 @@ var DEFAULT_DEPENDENCIES = { materializeProfileScene };
|
|
|
220
220
|
var PROFILE_EDGE_COLOR_SCHEME_RD_BU = (value) => interpolateRdBu(1 - value);
|
|
221
221
|
var PROFILE_EDGE_COLOR_SCHEME_RD_PU = interpolateRdPu;
|
|
222
222
|
var PROFILE_COST_COLOR_SCHEME_OR_RD = interpolateOrRd;
|
|
223
|
+
function edgeDifferenceColor(difference) {
|
|
224
|
+
return PROFILE_EDGE_COLOR_SCHEME_RD_BU(difference < 0 ? Math.max(0, (difference + 1) / 2) : Math.min(1, .5 + difference / 4));
|
|
225
|
+
}
|
|
226
|
+
var legendGradient = (color) => Array.from({ length: 11 }, (_, index) => color(index / 10)).join(", ");
|
|
227
|
+
var ESTIMATE_LEGEND_GRADIENT = legendGradient((value) => PROFILE_EDGE_COLOR_SCHEME_RD_BU(1 - value));
|
|
228
|
+
var ROW_LEGEND_GRADIENT = legendGradient(PROFILE_EDGE_COLOR_SCHEME_RD_PU);
|
|
229
|
+
var COST_LEGEND_GRADIENT = legendGradient(PROFILE_COST_COLOR_SCHEME_OR_RD);
|
|
223
230
|
function contrastingTextColor(background) {
|
|
224
231
|
const rgb = color(background)?.rgb();
|
|
225
232
|
if (rgb == null) return "#000000";
|
|
@@ -281,11 +288,11 @@ function placeOperatorAnnotation(operator, input) {
|
|
|
281
288
|
y: operator.rect.y
|
|
282
289
|
};
|
|
283
290
|
}
|
|
284
|
-
function QueryProfileView({ plan, execution = ProfileExecutionState.EMPTY, showProgress = false,
|
|
291
|
+
function QueryProfileView({ plan, execution = ProfileExecutionState.EMPTY, showProgress = false, autoFocus = false, fill = false, onRotate, dependencies = DEFAULT_DEPENDENCIES }) {
|
|
285
292
|
const scene = React.useMemo(() => dependencies.materializeProfileScene(plan), [dependencies, plan]);
|
|
286
|
-
const
|
|
287
|
-
|
|
288
|
-
const controller = controllerRef
|
|
293
|
+
const controllerRef = React.useRef(null);
|
|
294
|
+
controllerRef.current ??= new ProfileExecutionController();
|
|
295
|
+
const controller = controllerRef.current;
|
|
289
296
|
const viewportRef = React.useRef(null);
|
|
290
297
|
const svgRef = React.useRef(null);
|
|
291
298
|
const sceneRef = React.useRef(null);
|
|
@@ -297,13 +304,6 @@ function QueryProfileView({ plan, execution = ProfileExecutionState.EMPTY, showP
|
|
|
297
304
|
const [fragmentColors, setFragmentColors] = React.useState(false);
|
|
298
305
|
const operatorRefs = React.useRef(/* @__PURE__ */ new Map());
|
|
299
306
|
const [positionRevision, setPositionRevision] = React.useState(0);
|
|
300
|
-
const edgeColorScheme = edgeRendering?.colorScheme ?? PROFILE_EDGE_COLOR_SCHEME_RD_BU;
|
|
301
|
-
const rowColorScheme = edgeRendering?.rowColorScheme ?? PROFILE_EDGE_COLOR_SCHEME_RD_PU;
|
|
302
|
-
const costColorScheme = edgeRendering?.costColorScheme ?? PROFILE_COST_COLOR_SCHEME_OR_RD;
|
|
303
|
-
const edgeDifferenceColor = React.useCallback((difference) => edgeColorScheme(difference < 0 ? Math.max(0, (difference + 1) / 2) : Math.min(1, .5 + difference / 4)), [edgeColorScheme]);
|
|
304
|
-
const estimateLegendGradient = React.useMemo(() => Array.from({ length: 11 }, (_, index) => edgeColorScheme(1 - index / 10)).join(", "), [edgeColorScheme]);
|
|
305
|
-
const rowLegendGradient = React.useMemo(() => Array.from({ length: 11 }, (_, index) => rowColorScheme(index / 10)).join(", "), [rowColorScheme]);
|
|
306
|
-
const costLegendGradient = React.useMemo(() => Array.from({ length: 11 }, (_, index) => costColorScheme(index / 10)).join(", "), [costColorScheme]);
|
|
307
307
|
const actualRows = React.useMemo(() => scene.edges.map((edge) => {
|
|
308
308
|
const rows = execution.edgeRows(edge.slot, edge.childOperator);
|
|
309
309
|
return rows == null ? null : Number(rows);
|
|
@@ -365,7 +365,7 @@ function QueryProfileView({ plan, execution = ProfileExecutionState.EMPTY, showP
|
|
|
365
365
|
return [{
|
|
366
366
|
operator: operator.id,
|
|
367
367
|
edge: null,
|
|
368
|
-
badge: badge(operator, formatCpuShare(share),
|
|
368
|
+
badge: badge(operator, formatCpuShare(share), PROFILE_COST_COLOR_SCHEME_OR_RD(max === 0 ? 0 : value / max), `CPU ${formatElapsed(value / 1e3)}, ${formatCpuShare(share)} of the CPU time of all operators`)
|
|
369
369
|
}];
|
|
370
370
|
});
|
|
371
371
|
}
|
|
@@ -379,7 +379,7 @@ function QueryProfileView({ plan, execution = ProfileExecutionState.EMPTY, showP
|
|
|
379
379
|
return [{
|
|
380
380
|
operator: operator.id,
|
|
381
381
|
edge: null,
|
|
382
|
-
badge: badge(operator, formatShortBytes(value),
|
|
382
|
+
badge: badge(operator, formatShortBytes(value), PROFILE_COST_COLOR_SCHEME_OR_RD(max === 0 ? 0 : value / max), `Memory ${formatCompactBytes(value)}${spilledBytes > 0 ? `, spilled ${formatCompactBytes(spilledBytes)} to disk` : ""}`, spilledBytes > 0 ? SPILLED_BADGE_BORDER : null)
|
|
383
383
|
}];
|
|
384
384
|
});
|
|
385
385
|
}
|
|
@@ -393,8 +393,8 @@ function QueryProfileView({ plan, execution = ProfileExecutionState.EMPTY, showP
|
|
|
393
393
|
const actual = actualRows[edgeIndex];
|
|
394
394
|
const estimated = edge.outputCardinalityEstimated;
|
|
395
395
|
let annotation = null;
|
|
396
|
-
if (annotationMode === "rows" && actual != null) annotation = badge(child, formatCompactCount(actual),
|
|
397
|
-
else if (annotationMode === "estimates" && estimated != null) annotation = badge(child, formatCompactCount(estimated),
|
|
396
|
+
if (annotationMode === "rows" && actual != null) annotation = badge(child, formatCompactCount(actual), PROFILE_EDGE_COLOR_SCHEME_RD_PU(rowScale(actual)), `Actual rows ${formatRowCount(actual)}`);
|
|
397
|
+
else if (annotationMode === "estimates" && estimated != null) annotation = badge(child, formatCompactCount(estimated), PROFILE_EDGE_COLOR_SCHEME_RD_PU(rowScale(estimated)), `Estimated rows ${formatRowCount(Math.round(estimated))}`);
|
|
398
398
|
else if (annotationMode === "accuracy" && actual != null && estimated != null) {
|
|
399
399
|
const difference = estimateRelativeDifference(estimated, actual);
|
|
400
400
|
annotation = badge(child, formatEstimateSymbol(difference, Math.abs(actual - estimated)), edgeDifferenceColor(difference), `Actual rows ${formatRowCount(actual)}, estimated rows ${formatRowCount(Math.round(estimated))}, difference ${formatRelativeDifference(difference)}`);
|
|
@@ -409,10 +409,7 @@ function QueryProfileView({ plan, execution = ProfileExecutionState.EMPTY, showP
|
|
|
409
409
|
scene,
|
|
410
410
|
execution,
|
|
411
411
|
actualRows,
|
|
412
|
-
annotationMode
|
|
413
|
-
rowColorScheme,
|
|
414
|
-
costColorScheme,
|
|
415
|
-
edgeDifferenceColor
|
|
412
|
+
annotationMode
|
|
416
413
|
]);
|
|
417
414
|
const spilled = React.useMemo(() => annotationMode === "memory" && annotations.some((annotation) => annotation.badge.border != null), [annotationMode, annotations]);
|
|
418
415
|
const annotationWidths = React.useMemo(() => {
|
|
@@ -449,13 +446,8 @@ function QueryProfileView({ plan, execution = ProfileExecutionState.EMPTY, showP
|
|
|
449
446
|
React.useLayoutEffect(() => {
|
|
450
447
|
controller.reset(scene.operators.length, scene.pipelines.length);
|
|
451
448
|
controller.applyState(execution, scene.operators.map((operator) => operator.fragment));
|
|
452
|
-
if (controllerRef != null) controllerRef.current = controller;
|
|
453
|
-
return () => {
|
|
454
|
-
if (controllerRef != null) controllerRef.current = null;
|
|
455
|
-
};
|
|
456
449
|
}, [
|
|
457
450
|
controller,
|
|
458
|
-
controllerRef,
|
|
459
451
|
scene,
|
|
460
452
|
execution
|
|
461
453
|
]);
|
|
@@ -596,7 +588,7 @@ function QueryProfileView({ plan, execution = ProfileExecutionState.EMPTY, showP
|
|
|
596
588
|
/* @__PURE__ */ jsx("span", { children: "More rows" }),
|
|
597
589
|
/* @__PURE__ */ jsx("i", {
|
|
598
590
|
"aria-hidden": "true",
|
|
599
|
-
style: { backgroundImage: `linear-gradient(to right, ${
|
|
591
|
+
style: { backgroundImage: `linear-gradient(to right, ${ROW_LEGEND_GRADIENT})` }
|
|
600
592
|
})
|
|
601
593
|
]
|
|
602
594
|
})
|
|
@@ -612,7 +604,7 @@ function QueryProfileView({ plan, execution = ProfileExecutionState.EMPTY, showP
|
|
|
612
604
|
/* @__PURE__ */ jsx("span", { children: annotationMode === "cpu" ? "More CPU" : "More memory" }),
|
|
613
605
|
/* @__PURE__ */ jsx("i", {
|
|
614
606
|
"aria-hidden": "true",
|
|
615
|
-
style: { backgroundImage: `linear-gradient(to right, ${
|
|
607
|
+
style: { backgroundImage: `linear-gradient(to right, ${COST_LEGEND_GRADIENT})` }
|
|
616
608
|
}),
|
|
617
609
|
spilled && /* @__PURE__ */ jsx("span", {
|
|
618
610
|
className: "dashql_edge_legend_note_IVlaV2",
|
|
@@ -634,7 +626,7 @@ function QueryProfileView({ plan, execution = ProfileExecutionState.EMPTY, showP
|
|
|
634
626
|
/* @__PURE__ */ jsx("i", {
|
|
635
627
|
"aria-hidden": "true",
|
|
636
628
|
"data-testid": "plan-legend-gradient",
|
|
637
|
-
style: { backgroundImage: `linear-gradient(to right, ${
|
|
629
|
+
style: { backgroundImage: `linear-gradient(to right, ${ESTIMATE_LEGEND_GRADIENT})` }
|
|
638
630
|
}),
|
|
639
631
|
/* @__PURE__ */ jsx("span", {
|
|
640
632
|
className: edge_legend_matched,
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import type { TopLevelSpec } from 'vega-lite';
|
|
3
3
|
import type { View } from 'vega';
|
|
4
|
-
import { type VegaModules } from '../vegalite/vegalite_loader.js';
|
|
5
4
|
import { type ChartColors } from '../vegalite/vegalite_theme.js';
|
|
6
5
|
export type VegaDatasets = Readonly<Record<string, readonly object[]>>;
|
|
7
6
|
export type VegaSignals = Readonly<Record<string, unknown>>;
|
|
@@ -11,7 +10,6 @@ interface Props {
|
|
|
11
10
|
signals?: VegaSignals;
|
|
12
11
|
className?: string;
|
|
13
12
|
onView?: (view: View | null) => void;
|
|
14
|
-
loader?: () => Promise<VegaModules>;
|
|
15
13
|
'data-testid'?: string;
|
|
16
14
|
}
|
|
17
15
|
export declare function VegaLiteChart(props: Props): React.ReactElement;
|
|
@@ -63,7 +63,6 @@ function VegaLiteChart(props) {
|
|
|
63
63
|
};
|
|
64
64
|
const onView = React.useRef(props.onView);
|
|
65
65
|
onView.current = props.onView;
|
|
66
|
-
const loader = props.loader ?? loadVega;
|
|
67
66
|
const colorScheme = useColorScheme();
|
|
68
67
|
const flavorId = useBrand().id;
|
|
69
68
|
const datasetSizes = Object.fromEntries(Object.entries(props.datasets).map(([name, items]) => [`data-dataset-${name}`, items.length]));
|
|
@@ -74,7 +73,7 @@ function VegaLiteChart(props) {
|
|
|
74
73
|
let disposed = false;
|
|
75
74
|
let view = null;
|
|
76
75
|
setReady(false);
|
|
77
|
-
|
|
76
|
+
loadVega().then(async ({ embed, vega, expressionInterpreter }) => {
|
|
78
77
|
if (disposed) return;
|
|
79
78
|
const colors = resolveChartColors();
|
|
80
79
|
const runtimeSpec = {
|
|
@@ -118,7 +117,6 @@ function VegaLiteChart(props) {
|
|
|
118
117
|
};
|
|
119
118
|
}, [
|
|
120
119
|
spec,
|
|
121
|
-
loader,
|
|
122
120
|
colorScheme,
|
|
123
121
|
flavorId
|
|
124
122
|
]);
|