Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Add Error Message for Explain and Run #872

Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions workbench/public/components/Main/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export function getQueryResultsForTable(
if (!queryResultResponseDetail.fulfilled) {
return {
fulfilled: queryResultResponseDetail.fulfilled,
errorMessage: queryResultResponseDetail.errorMessage,
errorMessage: queryResultResponseDetail.errorMessage + ', this query is not runnable.',
};
} else {
let databaseRecords: { [key: string]: any }[] = [];
Expand Down Expand Up @@ -332,7 +332,6 @@ export class Main extends React.Component<MainProps, MainState> {
this.processQueryResponse(response as IHttpResponse<ResponseData>)
);
const resultTable: ResponseDetail<QueryResult>[] = getQueryResultsForTable(results);

this.setState(
{
queries: queries,
Expand Down
19 changes: 18 additions & 1 deletion workbench/public/components/PPLPage/PPLPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,23 @@ export class PPLPage extends React.Component<PPLPageProps, PPLPageState> {
const closeModal = () => this.setIsModalVisible(false);
const showModal = () => this.setIsModalVisible(true);

const pplTranslationsNotEmpty = () => {
if (this.props.pplTranslations.length > 0) {
return this.props.pplTranslations[0].fulfilled;
}
return false;
}

const showExplainErrorMessage = () => {
return this.props.pplTranslations.map((queryTranslation: any) => JSON.stringify(
queryTranslation.errorMessage + ": This query is not explainable.", null, 2
));
}

const explainContent = pplTranslationsNotEmpty()
? this.props.pplTranslations.map((queryTranslation: any) => JSON.stringify(queryTranslation.data, null, 2)).join("\n")
: showExplainErrorMessage();

let modal;

if (this.state.isModalVisible) {
Expand All @@ -85,7 +102,7 @@ export class PPLPage extends React.Component<PPLPageProps, PPLPageState> {
fontSize="m"
isCopyable
>
{this.props.pplTranslations.map((queryTranslation: any) => JSON.stringify(queryTranslation.data, null, 2)).join("\n")}
{explainContent}
</EuiCodeBlock>
</EuiModalBody>

Expand Down
24 changes: 22 additions & 2 deletions workbench/public/components/SQLPage/SQLPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,23 @@ export class SQLPage extends React.Component<SQLPageProps, SQLPageState> {
const closeModal = () => this.setIsModalVisible(false);
const showModal = () => this.setIsModalVisible(true);

const sqlTranslationsNotEmpty = () => {
if (this.props.sqlTranslations.length > 0) {
return this.props.sqlTranslations[0].fulfilled;
}
return false;
}

const showExplainErrorMessage = () => {
return this.props.sqlTranslations.map((queryTranslation: any) => JSON.stringify(
queryTranslation.errorMessage + ": This query is not explainable.", null, 2
));
}

const explainContent = sqlTranslationsNotEmpty()
? this.props.sqlTranslations.map((queryTranslation: any) => JSON.stringify(queryTranslation.data, null, 2)).join("\n")
: showExplainErrorMessage();

let modal;

if (this.state.isModalVisible) {
Expand All @@ -88,7 +105,7 @@ export class SQLPage extends React.Component<SQLPageProps, SQLPageState> {
fontSize="m"
isCopyable
>
{this.props.sqlTranslations.map((queryTranslation: any) => JSON.stringify(queryTranslation.data, null, 2)).join("\n")}
{explainContent}
</EuiCodeBlock>
</EuiModalBody>

Expand Down Expand Up @@ -148,7 +165,10 @@ export class SQLPage extends React.Component<SQLPageProps, SQLPageState> {
this.props.onTranslate(this.props.sqlQuery)
}
>
<EuiButton className="sql-editor-button" onClick={showModal}>
<EuiButton
className="sql-editor-button"
onClick={showModal}
>
Explain
</EuiButton>
{modal}
Expand Down