You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2018/06/20 03:33:26 UTC

[GitHub] timifasubaa closed pull request #5216: [sqllab] Fix sql lab resolution link

timifasubaa closed pull request #5216: [sqllab] Fix sql lab resolution link
URL: https://github.com/apache/incubator-superset/pull/5216
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/superset/assets/src/SqlLab/actions.js b/superset/assets/src/SqlLab/actions.js
index 644947023b..540bfe7b03 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 f36a1640c7..49599214e5 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 318b0af005..55ff2a305f 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 9c67f3822c..690126d2f0 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 c9f07ae906..df00a2b6b1 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 handle_error(msg):
             'status': query.status,
             'error': msg,
         })
+        if troubleshooting_link:
+            payload['link'] = troubleshooting_link
         return payload
 
     if store_results and not results_backend:


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org