diff --git a/redash/metrics/database.py b/redash/metrics/database.py index 152427b2e5..6f16bdbc6d 100644 --- a/redash/metrics/database.py +++ b/redash/metrics/database.py @@ -5,7 +5,7 @@ from sqlalchemy.engine import Engine from sqlalchemy.event import listens_for from sqlalchemy.orm.util import _ORMJoin -from sqlalchemy.sql.selectable import Alias +from sqlalchemy.sql.selectable import Alias, Join from redash import statsd_client @@ -18,7 +18,7 @@ def _table_name_from_select_element(elt): if isinstance(t, Alias): t = t.original.froms[0] - while isinstance(t, _ORMJoin): + while isinstance(t, _ORMJoin) or isinstance(t, Join): t = t.left return t.name