Skip to content

Commit 33c5e53

Browse files
authored
Web console: minor tweaks and fixes (#17970)
* allow prefix editing when downloading * add parse JSON action * add unquote JSON action * add KEY and VALUE to keywords * adjust outer tick size * more keywords * rename * better download naming * use sed to update the config when building
1 parent a23170e commit 33c5e53

File tree

7 files changed

+193
-75
lines changed

7 files changed

+193
-75
lines changed

web-console/lib/keywords.ts

+19
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ export const SQL_KEYWORDS = [
5454
'ROW',
5555
'ROWS',
5656
'ONLY',
57+
'KEY',
58+
'VALUE',
5759
'VALUES',
5860
'PARTITIONED BY',
5961
'CLUSTERED BY',
@@ -76,6 +78,23 @@ export const SQL_KEYWORDS = [
7678
'UNPIVOT',
7779
'MATCHED',
7880
'UPDATE SET',
81+
'EPOCH',
82+
'MILLISECOND',
83+
'SECOND',
84+
'MINUTE',
85+
'HOUR',
86+
'DAY',
87+
'DOW',
88+
'ISODOW',
89+
'DOY',
90+
'WEEK',
91+
'MONTH',
92+
'QUARTER',
93+
'YEAR',
94+
'ISOYEAR',
95+
'DECADE',
96+
'CENTURY',
97+
'MILLENNIUM',
7998
];
8099

81100
export const SQL_EXPRESSION_PARTS = [

web-console/script/druid

+2-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ function _build_distribution() {
6464
&& cp "$(_get_code_root)/extensions-core/testing-tools/target/druid-testing-tools-$(_get_druid_version).jar" extensions/druid-testing-tools/ \
6565
&& mkdir -p extensions/druid-compressed-bigdecimal \
6666
&& cp "$(_get_code_root)/extensions-contrib/compressed-bigdecimal/target/druid-compressed-bigdecimal-$(_get_druid_version).jar" extensions/druid-compressed-bigdecimal/ \
67-
&& echo -e "\n\ndruid.extensions.loadList=[\"druid-hdfs-storage\", \"druid-kafka-indexing-service\", \"druid-multi-stage-query\", \"druid-testing-tools\", \"druid-bloom-filter\", \"druid-datasketches\", \"druid-histogram\", \"druid-stats\", \"druid-compressed-bigdecimal\", \"druid-parquet-extensions\", \"druid-deltalake-extensions\"]" >> conf/druid/auto/_common/common.runtime.properties \
67+
&& sed -i.bak 's/druid\.extensions\.loadList=\[\([^]]*\)\]/druid.extensions.loadList=[\1, "druid-testing-tools", "druid-bloom-filter", "druid-histogram", "druid-stats", "druid-compressed-bigdecimal", "druid-deltalake-extensions"]/' conf/druid/auto/_common/common.runtime.properties \
68+
&& rm conf/druid/auto/_common/common.runtime.properties.bak \
6869
&& echo -e "\n\ndruid.server.http.allowedHttpMethods=[\"HEAD\"]" >> conf/druid/auto/_common/common.runtime.properties \
6970
&& echo -e "\n\ndruid.export.storage.baseDir=/" >> conf/druid/auto/_common/common.runtime.properties \
7071
&& echo -e "\n\ndruid.msq.dart.enabled=true" >> conf/druid/auto/_common/common.runtime.properties \

web-console/src/views/explore-view/components/resource-pane/nested-column-dialog/nested-column-dialog.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ export const NestedColumnDialog = React.memo(function NestedColumnDialog(
178178
querySource.addColumnAfter(
179179
nestedColumn.getOutputName() || '',
180180
...selectedPaths.map(path =>
181-
F('JSON_VALUE', nestedColumn, path).as(
181+
SqlFunction.jsonValue(nestedColumn, path).as(
182182
querySource.getAvailableName(getOutputName(path)),
183183
),
184184
),

web-console/src/views/explore-view/modules/time-chart-module/continuous-chart-render.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -758,6 +758,7 @@ export const ContinuousChartRender = function ContinuousChartRender(
758758
select(node).call(
759759
axisLeft(measureScale)
760760
.ticks(3)
761+
.tickSizeOuter(0)
761762
.tickFormat(e => formatNumber(e.valueOf())),
762763
)
763764
}

web-console/src/views/workbench-view/destination-pages-pane/destination-pages-pane.scss

+6
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@
2020
display: flex;
2121
flex-direction: column;
2222

23+
.download-as-controls {
24+
width: 570px;
25+
display: inline-flex;
26+
margin-right: 15px;
27+
}
28+
2329
.download-button {
2430
margin-top: 4px;
2531
margin-left: 2px;

web-console/src/views/workbench-view/destination-pages-pane/destination-pages-pane.tsx

+49-29
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,18 @@
1616
* limitations under the License.
1717
*/
1818

19-
import { AnchorButton, Button, Intent, Menu, MenuItem, Popover, Position } from '@blueprintjs/core';
19+
import {
20+
AnchorButton,
21+
Button,
22+
ControlGroup,
23+
InputGroup,
24+
Intent,
25+
Label,
26+
Menu,
27+
MenuItem,
28+
Popover,
29+
Position,
30+
} from '@blueprintjs/core';
2031
import { IconNames } from '@blueprintjs/icons';
2132
import React, { useState } from 'react';
2233
import ReactTable from 'react-table';
@@ -47,7 +58,7 @@ function resultFormatToExtension(resultFormat: ResultFormat): string {
4758
}
4859
}
4960

50-
const RESULT_FORMAT_LABEL: Record<ResultFormat, string> = {
61+
const RESULT_FORMAT_DESCRIPTION: Record<ResultFormat, string> = {
5162
object: 'Array of objects',
5263
array: 'Array of arrays',
5364
objectLines: 'JSON Lines',
@@ -63,34 +74,34 @@ export const DestinationPagesPane = React.memo(function DestinationPagesPane(
6374
props: DestinationPagesPaneProps,
6475
) {
6576
const { execution } = props;
77+
const [prefix, setPrefix] = useState(execution.id);
6678
const [desiredResultFormat, setDesiredResultFormat] = useState<ResultFormat>('objectLines');
6779
const desiredExtension = resultFormatToExtension(desiredResultFormat);
6880

6981
const destination = execution.destination;
7082
const pages = execution.destinationPages;
7183
if (!pages) return null;
7284
const numPages = pages.length;
73-
const id = Api.encodePath(execution.id);
7485

7586
const numTotalRows = destination?.numTotalRows;
7687

7788
function getResultUrl(pageIndex: number) {
7889
return UrlBaser.base(
79-
`/druid/v2/sql/statements/${id}/results?${
90+
`/druid/v2/sql/statements/${Api.encodePath(execution.id)}/results?${
8091
pageIndex < 0 ? '' : `page=${pageIndex}&`
8192
}resultFormat=${desiredResultFormat}&filename=${getPageFilename(pageIndex)}`,
8293
);
8394
}
8495

8596
function getFilenamePageInfo(pageIndex: number) {
86-
if (pageIndex < 0) return 'all_data';
97+
if (pageIndex < 0) return '';
8798
const numPagesString = String(numPages);
8899
const pageNumberString = String(pageIndex + 1).padStart(numPagesString.length, '0');
89-
return `page_${pageNumberString}_of_${numPagesString}`;
100+
return `.page_${pageNumberString}_of_${numPagesString}`;
90101
}
91102

92103
function getPageFilename(pageIndex: number) {
93-
return `${id}_${getFilenamePageInfo(pageIndex)}.${desiredExtension}`;
104+
return `${prefix}${getFilenamePageInfo(pageIndex)}.${desiredExtension}`;
94105
}
95106

96107
return (
@@ -101,29 +112,38 @@ export const DestinationPagesPane = React.memo(function DestinationPagesPane(
101112
} have been written to ${pluralIfNeeded(numPages, 'page')}. `}
102113
</p>
103114
<p>
104-
Format when downloading:{' '}
105-
<Popover
106-
minimal
107-
position={Position.BOTTOM_LEFT}
108-
content={
109-
<Menu>
110-
{RESULT_FORMATS.map((resultFormat, i) => (
111-
<MenuItem
112-
key={i}
113-
icon={tickIcon(desiredResultFormat === resultFormat)}
114-
text={RESULT_FORMAT_LABEL[resultFormat]}
115-
label={resultFormat}
116-
onClick={() => setDesiredResultFormat(resultFormat)}
117-
/>
118-
))}
119-
</Menu>
120-
}
121-
>
122-
<Button
123-
text={RESULT_FORMAT_LABEL[desiredResultFormat]}
124-
rightIcon={IconNames.CARET_DOWN}
115+
<Label>Download as</Label>
116+
<ControlGroup className="download-as-controls">
117+
<InputGroup
118+
value={prefix}
119+
onChange={(e: any) => setPrefix(e.target.value.slice(0, 200))}
120+
placeholder="file_prefix"
121+
rightElement={<Button disabled text={`.${desiredExtension}`} />}
122+
fill
125123
/>
126-
</Popover>{' '}
124+
<Popover
125+
minimal
126+
position={Position.BOTTOM_LEFT}
127+
content={
128+
<Menu>
129+
{RESULT_FORMATS.map((resultFormat, i) => (
130+
<MenuItem
131+
key={i}
132+
icon={tickIcon(desiredResultFormat === resultFormat)}
133+
text={RESULT_FORMAT_DESCRIPTION[resultFormat]}
134+
label={resultFormat}
135+
onClick={() => setDesiredResultFormat(resultFormat)}
136+
/>
137+
))}
138+
</Menu>
139+
}
140+
>
141+
<Button
142+
text={RESULT_FORMAT_DESCRIPTION[desiredResultFormat]}
143+
rightIcon={IconNames.CARET_DOWN}
144+
/>
145+
</Popover>
146+
</ControlGroup>
127147
<AnchorButton
128148
intent={Intent.PRIMARY}
129149
icon={IconNames.DOWNLOAD}

0 commit comments

Comments
 (0)