Merge pull request #2428 from toru-takahashi/master

Improve a query failure message for Treasure Data Runner
This commit is contained in:
Arik Fraimovich 2018-04-12 15:14:24 +03:00 committed by GitHub
commit 7465c74392
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -8,6 +8,7 @@ logger = logging.getLogger(__name__)
try:
import tdclient
from tdclient import errors
enabled = True
except ImportError:
@ -102,7 +103,7 @@ class TreasureData(BaseQueryRunner):
db=self.configuration.get('db'))
cursor = connection.cursor()
try:
cursor.execute(query)
columns_data = [(row[0], cursor.show_job()['hive_result_schema'][i][1]) for i,row in enumerate(cursor.description)]
@ -117,7 +118,9 @@ class TreasureData(BaseQueryRunner):
data = {'columns': columns, 'rows': rows}
json_data = json.dumps(data, cls=JSONEncoder)
error = None
except errors.InternalError as e:
json_data = None
error = "%s: %s" % (e.message, cursor.show_job().get('debug', {}).get('stderr', 'No stderr message in the response')
return json_data, error
register(TreasureData)