This is an automated email from the ASF dual-hosted git repository. timi pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-superset.git
The following commit(s) were added to refs/heads/master by this push: new 93cdf60 [sqllab] Fix sql lab resolution link (#5216) 93cdf60 is described below commit 93cdf60920dc6234771876a195838c6458b80e3d Author: timifasubaa <30888507+timifasu...@users.noreply.github.com> AuthorDate: Tue Jun 19 20:33:24 2018 -0700 [sqllab] Fix sql lab resolution link (#5216) * pass link * update frontend to show link differently * nits --- superset/assets/src/SqlLab/actions.js | 16 ++++++++++++---- superset/assets/src/SqlLab/components/ResultSet.jsx | 6 +++++- superset/assets/src/SqlLab/components/SouthPane.jsx | 1 - superset/assets/src/SqlLab/reducers.js | 7 ++++++- superset/sql_lab.py | 5 ++--- 5 files changed, 25 insertions(+), 10 deletions(-) diff --git a/superset/assets/src/SqlLab/actions.js b/superset/assets/src/SqlLab/actions.js index 6449470..540bfe7 100644 --- a/superset/assets/src/SqlLab/actions.js +++ b/superset/assets/src/SqlLab/actions.js @@ -78,8 +78,8 @@ export function querySuccess(query, results) { return { type: QUERY_SUCCESS, query, results }; } -export function queryFailed(query, msg) { - return { type: QUERY_FAILED, query, msg }; +export function queryFailed(query, msg, link) { + return { type: QUERY_FAILED, query, msg, link }; } export function stopQuery(query) { @@ -98,6 +98,14 @@ export function requestQueryResults(query) { return { type: REQUEST_QUERY_RESULTS, query }; } +function getErrorLink(err) { + let link = ''; + if (err.responseJSON && err.responseJSON.link) { + link = err.responseJSON.link; + } + return link; +} + export function fetchQueryResults(query) { return function (dispatch) { dispatch(requestQueryResults(query)); @@ -114,7 +122,7 @@ export function fetchQueryResults(query) { if (err.responseJSON && err.responseJSON.error) { msg = err.responseJSON.error; } - dispatch(queryFailed(query, msg)); + dispatch(queryFailed(query, msg, getErrorLink(err))); }, }); }; @@ -166,7 +174,7 @@ export function runQuery(query) { if (msg.indexOf('CSRF token') > 0) { msg = COMMON_ERR_MESSAGES.SESSION_TIMED_OUT; } - dispatch(queryFailed(query, msg)); + dispatch(queryFailed(query, msg, getErrorLink(msg))); }, }); }; diff --git a/superset/assets/src/SqlLab/components/ResultSet.jsx b/superset/assets/src/SqlLab/components/ResultSet.jsx index f36a164..4959921 100644 --- a/superset/assets/src/SqlLab/components/ResultSet.jsx +++ b/superset/assets/src/SqlLab/components/ResultSet.jsx @@ -155,7 +155,11 @@ export default class ResultSet extends React.PureComponent { if (query.state === 'stopped') { return <Alert bsStyle="warning">Query was stopped</Alert>; } else if (query.state === 'failed') { - return <Alert bsStyle="danger">{query.errorMessage}</Alert>; + return ( + <Alert bsStyle="danger"> + {query.errorMessage} + {query.link && <a href={query.link}> {t('(Common errors and their resolutions)')} </a>} + </Alert>); } else if (query.state === 'success' && query.ctas) { return ( <div> diff --git a/superset/assets/src/SqlLab/components/SouthPane.jsx b/superset/assets/src/SqlLab/components/SouthPane.jsx index 318b0af..55ff2a3 100644 --- a/superset/assets/src/SqlLab/components/SouthPane.jsx +++ b/superset/assets/src/SqlLab/components/SouthPane.jsx @@ -51,7 +51,6 @@ class SouthPane extends React.PureComponent { } else { results = <Alert bsStyle="info">{t('Run a query to display results here')}</Alert>; } - const dataPreviewTabs = props.dataPreviewQueries.map(query => ( <Tab title={t('Preview for %s', query.tableName)} diff --git a/superset/assets/src/SqlLab/reducers.js b/superset/assets/src/SqlLab/reducers.js index 9c67f38..690126d 100644 --- a/superset/assets/src/SqlLab/reducers.js +++ b/superset/assets/src/SqlLab/reducers.js @@ -181,7 +181,12 @@ export const sqlLabReducer = function (state, action) { if (action.query.state === 'stopped') { return state; } - const alts = { state: 'failed', errorMessage: action.msg, endDttm: now() }; + const alts = { + state: 'failed', + errorMessage: action.msg, + endDttm: now(), + link: action.link, + }; return alterInObject(state, 'queries', action.query, alts); }, [actions.SET_ACTIVE_QUERY_EDITOR]() { diff --git a/superset/sql_lab.py b/superset/sql_lab.py index c9f07ae..df00a2b 100644 --- a/superset/sql_lab.py +++ b/superset/sql_lab.py @@ -152,9 +152,6 @@ def execute_sql( def handle_error(msg): """Local method handling error while processing the SQL""" troubleshooting_link = config['TROUBLESHOOTING_LINK'] - msg = 'Error: {}. You can find common superset errors and their \ - resolutions at: {}'.format(msg, troubleshooting_link) \ - if troubleshooting_link else msg query.error_message = msg query.status = QueryStatus.FAILED query.tmp_table_name = None @@ -163,6 +160,8 @@ def execute_sql( 'status': query.status, 'error': msg, }) + if troubleshooting_link: + payload['link'] = troubleshooting_link return payload if store_results and not results_backend: