This is an automated email from the ASF dual-hosted git repository.
jackie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pinot.git
The following commit(s) were added to refs/heads/master by this push:
new 79ad59ae4d fix(ui): show query result along with error message if both
exist (#10071)
79ad59ae4d is described below
commit 79ad59ae4d8b79a2c699ec07f5b1984dfe5d1729
Author: Jayesh Choudhary <[email protected]>
AuthorDate: Wed Jan 11 04:18:16 2023 +0530
fix(ui): show query result along with error message if both exist (#10071)
---
.../src/main/resources/app/pages/Query.tsx | 161 ++++++++++-----------
.../main/resources/app/utils/PinotMethodUtils.ts | 18 ++-
2 files changed, 90 insertions(+), 89 deletions(-)
diff --git a/pinot-controller/src/main/resources/app/pages/Query.tsx
b/pinot-controller/src/main/resources/app/pages/Query.tsx
index 1974be4376..addc2279ee 100644
--- a/pinot-controller/src/main/resources/app/pages/Query.tsx
+++ b/pinot-controller/src/main/resources/app/pages/Query.tsx
@@ -553,93 +553,92 @@ const QueryPage = () => {
</Alert>
)
}
-
- {resultError ? (
+
+ {/* Sql result errors */}
+ {resultError && (
<Alert severity="error" className={classes.sqlError}>
{resultError}
</Alert>
- ) : (
- <>
- <Grid item xs style={{ backgroundColor: 'white' }}>
- {resultData.columns.length ? (
- <>
- <Grid container className={classes.actionBtns}>
- <Button
- variant="contained"
- color="primary"
- size="small"
- className={classes.btn}
- onClick={() => downloadData('xls')}
- >
- Excel
- </Button>
- <Button
- variant="contained"
- color="primary"
- size="small"
- className={classes.btn}
- onClick={() => downloadData('csv')}
- >
- CSV
- </Button>
- <Button
- variant="contained"
+ )}
+
+ <Grid item xs style={{ backgroundColor: 'white' }}>
+ {resultData.columns.length ? (
+ <>
+ <Grid container className={classes.actionBtns}>
+ <Button
+ variant="contained"
+ color="primary"
+ size="small"
+ className={classes.btn}
+ onClick={() => downloadData('xls')}
+ >
+ Excel
+ </Button>
+ <Button
+ variant="contained"
+ color="primary"
+ size="small"
+ className={classes.btn}
+ onClick={() => downloadData('csv')}
+ >
+ CSV
+ </Button>
+ <Button
+ variant="contained"
+ color="primary"
+ size="small"
+ className={classes.btn}
+ onClick={() => copyToClipboard()}
+ >
+ Copy
+ </Button>
+ {copyMsg ? (
+ <Alert
+ icon={<FileCopyIcon fontSize="inherit" />}
+ severity="info"
+ >
+ Copied {resultData.records.length} rows to
+ Clipboard
+ </Alert>
+ ) : null}
+
+ <FormControlLabel
+ control={
+ <Switch
+ checked={checked.showResultJSON}
+ onChange={handleChange}
+ name="showResultJSON"
color="primary"
- size="small"
- className={classes.btn}
- onClick={() => copyToClipboard()}
- >
- Copy
- </Button>
- {copyMsg ? (
- <Alert
- icon={<FileCopyIcon fontSize="inherit" />}
- severity="info"
- >
- Copied {resultData.records.length} rows to
- Clipboard
- </Alert>
- ) : null}
-
- <FormControlLabel
- control={
- <Switch
- checked={checked.showResultJSON}
- onChange={handleChange}
- name="showResultJSON"
- color="primary"
- />
- }
- label="Show JSON format"
- className={classes.runNowBtn}
/>
- </Grid>
- {!checked.showResultJSON ? (
- <CustomizedTables
- title="Query Result"
- data={resultData}
- isSticky={true}
- showSearchBox={true}
- inAccordionFormat={true}
- />
- ) : resultData.columns.length ? (
- <SimpleAccordion
- headerTitle="Query Result (JSON Format)"
- showSearchBox={false}
- >
- <CodeMirror
- options={jsonoptions}
- value={outputResult}
- className={classes.queryOutput}
- autoCursor={false}
- />
- </SimpleAccordion>
- ) : null}
- </>
+ }
+ label="Show JSON format"
+ className={classes.runNowBtn}
+ />
+ </Grid>
+ {!checked.showResultJSON ? (
+ <CustomizedTables
+ title="Query Result"
+ data={resultData}
+ isSticky={true}
+ showSearchBox={true}
+ inAccordionFormat={true}
+ />
+ ) : resultData.columns.length ? (
+ <SimpleAccordion
+ headerTitle="Query Result (JSON Format)"
+ showSearchBox={false}
+ >
+ <CodeMirror
+ options={jsonoptions}
+ value={outputResult}
+ className={classes.queryOutput}
+ autoCursor={false}
+ />
+ </SimpleAccordion>
) : null}
- </Grid>
- </>
- )}
+ </>
+ ) : null}
+ </Grid>
</>
)}
</Grid>
diff --git a/pinot-controller/src/main/resources/app/utils/PinotMethodUtils.ts
b/pinot-controller/src/main/resources/app/utils/PinotMethodUtils.ts
index 8809db3946..c0d045f40b 100644
--- a/pinot-controller/src/main/resources/app/utils/PinotMethodUtils.ts
+++ b/pinot-controller/src/main/resources/app/utils/PinotMethodUtils.ts
@@ -272,15 +272,17 @@ const getQueryResults = (params) => {
// if sql api throws error, handle here
if(typeof queryResponse === 'string'){
errorStr = queryResponse;
- } else if (queryResponse && queryResponse.exceptions &&
queryResponse.exceptions.length) {
- errorStr = JSON.stringify(queryResponse.exceptions, null, 2);
- } else
- {
- if (queryResponse.resultTable?.dataSchema?.columnNames?.length)
- {
- columnList = queryResponse.resultTable.dataSchema.columnNames;
- dataArray = queryResponse.resultTable.rows;
+ }
+ if (queryResponse && queryResponse.exceptions &&
queryResponse.exceptions.length) {
+ try{
+ errorStr = JSON.stringify(queryResponse.exceptions, null, 2);
+ } catch {
+ errorStr = "";
}
+ }
+ if (queryResponse.resultTable?.dataSchema?.columnNames?.length) {
+ columnList = queryResponse.resultTable.dataSchema.columnNames;
+ dataArray = queryResponse.resultTable.rows;
}
const columnStats = ['timeUsedMs',
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]