From 8c708037e8f94bf5e2898f50f2a096aaf4a97ad6 Mon Sep 17 00:00:00 2001 From: Erik Ritter Date: Tue, 1 Oct 2019 07:45:12 -1000 Subject: [PATCH] [Presto] Handle uncaught exception in get_create_view (#8304) --- superset/db_engine_specs/presto.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/superset/db_engine_specs/presto.py b/superset/db_engine_specs/presto.py index 65d598868..f79f5d205 100644 --- a/superset/db_engine_specs/presto.py +++ b/superset/db_engine_specs/presto.py @@ -1036,18 +1036,21 @@ class PrestoEngineSpec(BaseEngineSpec): :param schema: Schema name :param table: Table (view) name """ + from pyhive.exc import DatabaseError + engine = cls.get_engine(database, schema) with closing(engine.raw_connection()) as conn: with closing(conn.cursor()) as cursor: sql = f"SHOW CREATE VIEW {schema}.{table}" - cls.execute(cursor, sql) try: + cls.execute(cursor, sql) polled = cursor.poll() - except Exception: # not a VIEW + + while polled: + time.sleep(0.2) + polled = cursor.poll() + except DatabaseError: # not a VIEW return None - while polled: - time.sleep(0.2) - polled = cursor.poll() rows = cls.fetch_data(cursor, 1) return rows[0][0]