superset-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From maximebeauche...@apache.org
Subject [incubator-superset] branch master updated: Improve hive/pyhive error message regex (#5502)
Date Fri, 27 Jul 2018 15:31:44 GMT
This is an automated email from the ASF dual-hosted git repository.

maximebeauchemin 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 cd55998  Improve hive/pyhive error message regex (#5502)
cd55998 is described below

commit cd55998d6319d8c3ce27f0b9a01e0e12f5300473
Author: Maxime Beauchemin <maximebeauchemin@gmail.com>
AuthorDate: Fri Jul 27 08:31:37 2018 -0700

    Improve hive/pyhive error message regex (#5502)
---
 superset/db_engine_specs.py   | 2 +-
 tests/db_engine_specs_test.py | 9 +++++++++
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/superset/db_engine_specs.py b/superset/db_engine_specs.py
index 5e5a304..ebc8802 100644
--- a/superset/db_engine_specs.py
+++ b/superset/db_engine_specs.py
@@ -1052,7 +1052,7 @@ class HiveEngineSpec(PrestoEngineSpec):
     @classmethod
     def extract_error_message(cls, e):
         msg = str(e)
-        match = re.search('errorMessage="(.*)", ', msg)
+        match = re.search(r'errorMessage="(.*?)(?<!\\)"', msg)
         if match:
             msg = match.group(1)
         return msg
diff --git a/tests/db_engine_specs_test.py b/tests/db_engine_specs_test.py
index 287114c..1b340b4 100644
--- a/tests/db_engine_specs_test.py
+++ b/tests/db_engine_specs_test.py
@@ -103,6 +103,15 @@ class DbEngineSpecsTestCase(SupersetTestCase):
             text_type(e),
             HiveEngineSpec.extract_error_message(e))
 
+        msg = (
+            'errorCode=10001, '
+            'errorMessage="Error while compiling statement"), operationHandle'
+            '=None)"'
+        )
+        self.assertEquals((
+            'Error while compiling statement'),
+            HiveEngineSpec.extract_error_message(Exception(msg)))
+
     def get_generic_database(self):
         return Database(sqlalchemy_uri='mysql://localhost')
 


Mime
View raw message