You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by ar...@apache.org on 2017/04/04 18:19:31 UTC
[1/2] incubator-airflow git commit: [AIRFLOW-947] Improve exceptions
for unavailable Presto cluster
Repository: incubator-airflow
Updated Branches:
refs/heads/master 70f1bf10a -> f5462c78f
[AIRFLOW-947] Improve exceptions for unavailable Presto cluster
This improves error logging when the Presto cluster is unavailable
and the underlying error is a 503 http response. This introspects
the error to prevent trying to access the 'message' attribute when
not present.
Project: http://git-wip-us.apache.org/repos/asf/incubator-airflow/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-airflow/commit/6dd4b3bc
Tree: http://git-wip-us.apache.org/repos/asf/incubator-airflow/tree/6dd4b3bc
Diff: http://git-wip-us.apache.org/repos/asf/incubator-airflow/diff/6dd4b3bc
Branch: refs/heads/master
Commit: 6dd4b3bc1f366e1f4f4b42d6781f1caee7a5827a
Parents: 70f1bf1
Author: Arthur Wiedmer <ar...@gmail.com>
Authored: Mon Mar 6 21:06:13 2017 -0800
Committer: Arthur Wiedmer <ar...@gmail.com>
Committed: Tue Apr 4 09:37:22 2017 -0700
----------------------------------------------------------------------
airflow/hooks/presto_hook.py | 26 ++++++++++++++++----------
1 file changed, 16 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-airflow/blob/6dd4b3bc/airflow/hooks/presto_hook.py
----------------------------------------------------------------------
diff --git a/airflow/hooks/presto_hook.py b/airflow/hooks/presto_hook.py
index f8f6ac8..768ff3f 100644
--- a/airflow/hooks/presto_hook.py
+++ b/airflow/hooks/presto_hook.py
@@ -54,6 +54,19 @@ class PrestoHook(DbApiHook):
def _strip_sql(sql):
return sql.strip().rstrip(';')
+ def _get_pretty_exception_message(self, e):
+ """
+ Parses some DatabaseError to provide a better error message
+ """
+ if (hasattr(e, 'message')
+ and 'errorName' in e.message
+ and 'message' in e.message):
+ return ('{name}: {message}'.format(
+ name=e.message['errorName'],
+ message=e.message['message']))
+ else:
+ return str(e)
+
def get_records(self, hql, parameters=None):
"""
Get a set of records from Presto
@@ -62,14 +75,7 @@ class PrestoHook(DbApiHook):
return super(PrestoHook, self).get_records(
self._strip_sql(hql), parameters)
except DatabaseError as e:
- if (hasattr(e, 'message') and
- 'errorName' in e.message and
- 'message' in e.message):
- # Use the structured error data in the raised exception
- raise PrestoException('{name}: {message}'.format(
- name=e.message['errorName'], message=e.message['message']))
- else:
- raise PrestoException(str(e))
+ raise PrestoException(self._parse_exception_message(e))
def get_first(self, hql, parameters=None):
"""
@@ -80,7 +86,7 @@ class PrestoHook(DbApiHook):
return super(PrestoHook, self).get_first(
self._strip_sql(hql), parameters)
except DatabaseError as e:
- raise PrestoException(e[0]['message'])
+ raise PrestoException(self._parse_exception_message(e))
def get_pandas_df(self, hql, parameters=None):
"""
@@ -92,7 +98,7 @@ class PrestoHook(DbApiHook):
cursor.execute(self._strip_sql(hql), parameters)
data = cursor.fetchall()
except DatabaseError as e:
- raise PrestoException(e[0]['message'])
+ raise PrestoException(self._parse_exception_message(e))
column_descriptions = cursor.description
if data:
df = pandas.DataFrame(data)
[2/2] incubator-airflow git commit: Merge pull request #2128 from
artwr/artwr-improve_presto_hook_error_when_cluster_is_unavailable
Posted by ar...@apache.org.
Merge pull request #2128 from artwr/artwr-improve_presto_hook_error_when_cluster_is_unavailable
Project: http://git-wip-us.apache.org/repos/asf/incubator-airflow/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-airflow/commit/f5462c78
Tree: http://git-wip-us.apache.org/repos/asf/incubator-airflow/tree/f5462c78
Diff: http://git-wip-us.apache.org/repos/asf/incubator-airflow/diff/f5462c78
Branch: refs/heads/master
Commit: f5462c78ff38ec59ec30c688097ff5bb3b3541bb
Parents: 70f1bf1 6dd4b3b
Author: Arthur Wiedmer <ar...@gmail.com>
Authored: Tue Apr 4 11:20:54 2017 -0700
Committer: Arthur Wiedmer <ar...@gmail.com>
Committed: Tue Apr 4 11:20:54 2017 -0700
----------------------------------------------------------------------
airflow/hooks/presto_hook.py | 26 ++++++++++++++++----------
1 file changed, 16 insertions(+), 10 deletions(-)
----------------------------------------------------------------------