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/07/26 22:17:57 UTC

[GitHub] mistercrunch closed pull request #5495: [sql lab] extract Hive error messages

mistercrunch closed pull request #5495: [sql lab] extract Hive error messages
URL: https://github.com/apache/incubator-superset/pull/5495
 
 
   

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/db_engine_specs.py b/superset/db_engine_specs.py
index cc1345e371..5e5a30414a 100644
--- a/superset/db_engine_specs.py
+++ b/superset/db_engine_specs.py
@@ -1051,10 +1051,10 @@ def adjust_database_uri(cls, uri, selected_schema=None):
 
     @classmethod
     def extract_error_message(cls, e):
-        try:
-            msg = e.message.status.errorMessage
-        except Exception:
-            msg = str(e)
+        msg = str(e)
+        match = re.search('errorMessage="(.*)", ', msg)
+        if match:
+            msg = match.group(1)
         return msg
 
     @classmethod
diff --git a/tests/db_engine_specs_test.py b/tests/db_engine_specs_test.py
index c85e23a26c..287114ccd7 100644
--- a/tests/db_engine_specs_test.py
+++ b/tests/db_engine_specs_test.py
@@ -4,6 +4,8 @@
 from __future__ import print_function
 from __future__ import unicode_literals
 
+from six import text_type
+
 from superset.db_engine_specs import (
     BaseEngineSpec, HiveEngineSpec, MssqlEngineSpec,
     MySQLEngineSpec, PrestoEngineSpec,
@@ -84,6 +86,23 @@ def test_job_2_launched_stage_2_stages_progress(self):
         """.split('\n')  # noqa ignore: E501
         self.assertEquals(60, HiveEngineSpec.progress(log))
 
+    def test_hive_error_msg(self):
+        msg = (
+            '{...} errorMessage="Error while compiling statement: FAILED: '
+            'SemanticException [Error 10001]: Line 4'
+            ':5 Table not found \'fact_ridesfdslakj\'", statusCode=3, '
+            'sqlState=\'42S02\', errorCode=10001)){...}')
+        self.assertEquals((
+            'Error while compiling statement: FAILED: '
+            'SemanticException [Error 10001]: Line 4:5 '
+            "Table not found 'fact_ridesfdslakj'"),
+            HiveEngineSpec.extract_error_message(Exception(msg)))
+
+        e = Exception("Some string that doesn't match the regex")
+        self.assertEquals(
+            text_type(e),
+            HiveEngineSpec.extract_error_message(e))
+
     def get_generic_database(self):
         return Database(sqlalchemy_uri='mysql://localhost')
 


 

----------------------------------------------------------------
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