class_docstr: Wrapper around the pyhive library.
  
  Notes:
  * the default auth_mechanism is PLAIN, to override it you
  can specify it in the ``extra`` of your connection in the UI
  * the default for run_set_variable_statements is true, if you
  are using impala you may need to set it to false in the
  ``extra`` of your connection in the UI
  
  :param hiveserver2_conn_id: Reference to the
      :ref: `Hive Server2 thrift service connection id <howto/connection:hiveserver2>`.
  :param schema: Hive database name.
class_docstr_tok: ["Wrapper","around","the","pyhive","library",".","Notes",":","*","the","default","auth_mechanism","is","PLAIN",",","to","override","it","you","can","specify","it","in","the","``","extra","``","of","your","connection","in","the","UI","*","the","default","for","run_set_variable_statements","is","true",",","if","you","are","using","impala","you","may","need","to","set","it","to","false","in","the","``","extra","``","of","your","connection","in","the","UI",":","param","hiveserver2_conn_id",":","Reference","to","the",":","ref",":","`","Hive","Server2","thrift","service","connection","id","<","howto\/connection",":","hiveserver2",">","`",".",":","param","schema",":","Hive","database","name","."]
code: def _get_results(
      self,
      sql: str | list[str],
      schema: str = "default",
      fetch_size: int | None = None,
      hive_conf: Iterable | Mapping | None = None,
  ) -> Any:
      from pyhive.exc import ProgrammingError
  
      if isinstance(sql, str):
          sql = [sql]
      previous_description = None
      with contextlib.closing(
          self.get_conn(schema)
      ) as conn, contextlib.closing(conn.cursor()) as cur:
          cur.arraysize = fetch_size or 1000
  
          # not all query services (e.g. impala AIRFLOW-4434) support the set command
  
          db = self.get_connection(self.hiveserver2_conn_id)  # type: ignore
  
          if db.extra_dejson.get("run_set_variable_statements", True):
              env_context = get_context_from_env_var()
              if hive_conf:
                  env_context.update(hive_conf)
              for k, v in env_context.items():
                  cur.execute(f"set {k}={v}")
  
          for statement in sql:
              cur.execute(statement)
              # we only get results of statements that returns
              lowered_statement = statement.lower().strip()
              if lowered_statement.startswith(
                  ("select", "with", "show")
              ) or (
                  lowered_statement.startswith("set")
                  and "=" not in lowered_statement
              ):
                  description = cur.description
                  if (
                      previous_description
                      and previous_description != description
                  ):
                      message = f"""The statements are producing different descriptions:
                                       Current: {description!r}
                                       Previous: {previous_description!r}"""
                      raise ValueError(message)
                  elif not previous_description:
                      previous_description = description
                      yield description
                  try:
                      # DB API 2 raises when no results are returned
                      # we're silencing here as some statements in the list
                      # may be `SET` or DDL
                      yield from cur
                  except ProgrammingError:
                      self.log.debug("get_results returned no records")
  
imports: from __future__ import annotations
  import contextlib
  import os
  import re
  import socket
  import subprocess
  import time
  import warnings
  from tempfile import NamedTemporaryFile, TemporaryDirectory
  from typing import TYPE_CHECKING, Any, Iterable, Mapping
  from airflow.exceptions import AirflowProviderDeprecationWarning
  import csv
  from airflow.configuration import conf
  from airflow.exceptions import AirflowException
  from airflow.hooks.base import BaseHook
  from airflow.providers.common.sql.hooks.sql import DbApiHook
  from airflow.security import utils
  from airflow.utils.helpers import as_flattened_list
  from airflow.utils.operator_helpers import AIRFLOW_VAR_NAME_FORMAT_MAPPING
label_desc: Use image node_id 2 for calling the HiveServer2Hook obj's underlying member method code with example usage: obj._get_results(sql, schema, fetch_size, hive_conf) without return types