class_docstr: Reuses PrestoEngineSpec functionality.
class_docstr_tok: ["Reuses","PrestoEngineSpec","functionality","."]
docstr: Updates progress information
docstr_tok: ["Updates","progress","information"]
code: def handle_cursor(  # pylint: disable=too-many-locals
      cls, cursor: Any, query: Query
  ) -> None:
      """Updates progress information"""
      # pylint: disable=import-outside-toplevel
      from pyhive import hive
  
      unfinished_states = (
          hive.ttypes.TOperationState.INITIALIZED_STATE,
          hive.ttypes.TOperationState.RUNNING_STATE,
      )
      polled = cursor.poll()
      last_log_line = 0
      tracking_url = None
      job_id = None
      query_id = query.id
      while polled.operationState in unfinished_states:
          # Queries don't terminate when user clicks the STOP button on SQL LAB.
          # Refresh session so that the `query.status` modified in stop_query in
          # views/core.py is reflected here.
          db.session.refresh(query)
          query = (
              db.session.query(type(query)).filter_by(id=query_id).one()
          )
          if query.status == QueryStatus.STOPPED:
              cursor.cancel()
              break
  
          try:
              logs = cursor.fetch_logs()
              log = "\n".join(logs) if logs else ""
          except Exception:  # pylint: disable=broad-except
              logger.warning("Call to GetLog() failed")
              log = ""
  
          if log:
              log_lines = log.splitlines()
              progress = cls.progress(log_lines)
              logger.info(
                  "Query %s: Progress total: %s",
                  str(query_id),
                  str(progress),
              )
              needs_commit = False
              if progress > query.progress:
                  query.progress = progress
                  needs_commit = True
              if not tracking_url:
                  tracking_url = cls.get_tracking_url_from_logs(
                      log_lines
                  )
                  if tracking_url:
                      job_id = tracking_url.split("/")[-2]
                      logger.info(
                          "Query %s: Found the tracking url: %s",
                          str(query_id),
                          tracking_url,
                      )
                      query.tracking_url = tracking_url
                      logger.info(
                          "Query %s: Job id: %s",
                          str(query_id),
                          str(job_id),
                      )
                      needs_commit = True
              if job_id and len(log_lines) > last_log_line:
                  # Wait for job id before logging things out
                  # this allows for prefixing all log lines and becoming
                  # searchable in something like Kibana
                  for l in log_lines[last_log_line:]:
                      logger.info(
                          "Query %s: [%s] %s",
                          str(query_id),
                          str(job_id),
                          l,
                      )
                  last_log_line = len(log_lines)
              if needs_commit:
                  db.session.commit()
          if sleep_interval := current_app.config.get(
              "HIVE_POLL_INTERVAL"
          ):
              logger.warning(
                  "HIVE_POLL_INTERVAL is deprecated and will be removed in 3.0. Please use DB_POLL_INTERVAL_SECONDS instead"
              )
          else:
              sleep_interval = current_app.config[
                  "DB_POLL_INTERVAL_SECONDS"
              ].get(cls.engine, 5)
          time.sleep(sleep_interval)
          polled = cursor.poll()
  
imports: from __future__ import annotations
  import logging
  import os
  import re
  import tempfile
  import time
  from datetime import datetime
  from typing import Any, TYPE_CHECKING
  from urllib import parse
  import numpy
  import pandas
  import pyarrow
  import pyarrow.parquet
  from flask import current_app, g
  from sqlalchemy import Column, text, types
  from sqlalchemy.engine.base import Engine
  from sqlalchemy.engine.reflection import Inspector
  from sqlalchemy.engine.url import URL
  from sqlalchemy.sql.expression import ColumnClause, Select
  from superset import db
  from superset.common.db_query_status import QueryStatus
  from superset.constants import TimeGrain
  from superset.databases.utils import make_url_safe
  from superset.db_engine_specs.base import BaseEngineSpec
  from superset.db_engine_specs.presto import PrestoEngineSpec
  from superset.exceptions import SupersetException
  from superset.extensions import cache_manager
  from superset.models.sql_lab import Query
  from superset.sql_parse import ParsedQuery, Table
  from superset.superset_typing import ResultSetColumnType
label_desc: Use image node_id 10 for calling the HiveEngineSpec obj's underlying member method code with example usage: obj.handle_cursor(cls, cursor, query) without return types