mirror of
https://github.com/apache/superset.git
synced 2026-04-19 08:04:53 +00:00
[sql lab] extract Hive error messages (#5495)
* [sql lab] extract Hive error messages So pyhive returns an exception object with a stringified thrift error object. This PR uses a regex to extract the errorMessage portion of that string. * Unit test
This commit is contained in:
committed by
GitHub
parent
54fba0f39c
commit
41286b7545
@@ -4,6 +4,8 @@ from __future__ import division
|
||||
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 @@ class DbEngineSpecsTestCase(SupersetTestCase):
|
||||
""".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')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user