diff --git a/superset/db_engine_specs/presto.py b/superset/db_engine_specs/presto.py index 6c014a5707ee..ebf8ec483326 100644 --- a/superset/db_engine_specs/presto.py +++ b/superset/db_engine_specs/presto.py @@ -51,6 +51,9 @@ config = app.config logger = logging.getLogger(__name__) +# See here: https://github.com/dropbox/PyHive/blob/8eb0aeab8ca300f3024655419b93dad926c1a351/pyhive/presto.py#L93 # pylint: disable=line-too-long +DEFAULT_PYHIVE_POLL_INTERVAL = 1 + def get_children(column: Dict[str, str]) -> List[Dict[str, str]]: """ @@ -729,6 +732,9 @@ def get_create_view( def handle_cursor(cls, cursor: Any, query: Query, session: Session) -> None: """Updates progress information""" query_id = query.id + poll_interval = query.database.connect_args.get( + "poll_interval", DEFAULT_PYHIVE_POLL_INTERVAL + ) logger.info("Query %i: Polling the cursor for progress", query_id) polled = cursor.poll() # poll returns dict -- JSON status information or ``None`` @@ -762,7 +768,7 @@ def handle_cursor(cls, cursor: Any, query: Query, session: Session) -> None: if progress > query.progress: query.progress = progress session.commit() - time.sleep(1) + time.sleep(poll_interval) logger.info("Query %i: Polling the cursor for progress", query_id) polled = cursor.poll() diff --git a/superset/models/core.py b/superset/models/core.py index 25922ac7915e..b16a8e72c0a9 100755 --- a/superset/models/core.py +++ b/superset/models/core.py @@ -244,6 +244,10 @@ def table_cache_timeout(self) -> Optional[int]: def default_schemas(self) -> List[str]: return self.get_extra().get("default_schemas", []) + @property + def connect_args(self) -> Dict[str, Any]: + return self.get_extra().get("engine_params", {}).get("connect_args", {}) + @classmethod def get_password_masked_url_from_uri( # pylint: disable=invalid-name cls, uri: str