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","."]
docstr: Return a Hive connection object.
docstr_tok: ["Return","a","Hive","connection","object","."]
code: def get_conn(self, schema: str | None = None) -> Any:
      """Return a Hive connection object."""
      username: str | None = None
      password: str | None = None
  
      db = self.get_connection(self.hiveserver2_conn_id)  # type: ignore
  
      if "authMechanism" in db.extra_dejson:
          warnings.warn(
              "The 'authMechanism' option is deprecated. Please use 'auth_mechanism'.",
              AirflowProviderDeprecationWarning,
              stacklevel=2,
          )
          db.extra_dejson["auth_mechanism"] = db.extra_dejson[
              "authMechanism"
          ]
          del db.extra_dejson["authMechanism"]
  
      auth_mechanism = db.extra_dejson.get("auth_mechanism", "NONE")
      if auth_mechanism == "NONE" and db.login is None:
          # we need to give a username
          username = "airflow"
      kerberos_service_name = None
      if conf.get("core", "security") == "kerberos":
          auth_mechanism = db.extra_dejson.get(
              "auth_mechanism", "KERBEROS"
          )
          kerberos_service_name = db.extra_dejson.get(
              "kerberos_service_name", "hive"
          )
  
      # pyhive uses GSSAPI instead of KERBEROS as a auth_mechanism identifier
      if auth_mechanism == "GSSAPI":
          self.log.warning(
              "Detected deprecated 'GSSAPI' for auth_mechanism for %s. Please use 'KERBEROS' instead",
              self.hiveserver2_conn_id,  # type: ignore
          )
          auth_mechanism = "KERBEROS"
  
      # Password should be set if and only if in LDAP or CUSTOM mode
      if auth_mechanism in ("LDAP", "CUSTOM"):
          password = db.password
  
      from pyhive.hive import connect
  
      return connect(
          host=db.host,
          port=db.port,
          auth=auth_mechanism,
          kerberos_service_name=kerberos_service_name,
          username=db.login or username,
          password=password,
          database=schema or db.schema or "default",
      )
  
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 1 for calling the HiveServer2Hook obj's underlying member method code with example usage: obj.get_conn(schema) and returns: connect