class_docstr: Wrapper to interact with the Hive Metastore.
  
  :param metastore_conn_id: reference to the
      :ref: `metastore thrift service connection id <howto/connection:hive_metastore>`.
class_docstr_tok: ["Wrapper","to","interact","with","the","Hive","Metastore",".",":","param","metastore_conn_id",":","reference","to","the",":","ref",":","`","metastore","thrift","service","connection","id","<","howto\/connection",":","hive_metastore",">","`","."]
docstr: Return the maximum value for all partitions with given field in a table.
  
  If only one partition key exist in the table, the key will be used as field.
  filter_map should be a partition_key:partition_value map and will be used to
  filter out partitions.
  
  :param schema: schema name.
  :param table_name: table name.
  :param field: partition key to get max partition from.
  :param filter_map: partition_key:partition_value map used for partition filtering.
  
  >>> hh = HiveMetastoreHook()
  >>> filter_map = {'ds': '2015-01-01'}
  >>> t = 'static_babynames_partitioned'
  >>> hh.max_partition(schema='airflow',        ... table_name=t, field='ds', filter_map=filter_map)
  '2015-01-01'
docstr_tok: ["Return","the","maximum","value","for","all","partitions","with","given","field","in","a","table",".","If","only","one","partition","key","exist","in","the","table",",","the","key","will","be","used","as","field",".","filter_map","should","be","a","partition_key",":","partition_value","map","and","will","be","used","to","filter","out","partitions",".",":","param","schema",":","schema","name",".",":","param","table_name",":","table","name",".",":","param","field",":","partition","key","to","get","max","partition","from",".",":","param","filter_map",":","partition_key",":","partition_value","map","used","for","partition","filtering",".",">",">",">","hh","=","HiveMetastoreHook","(",")",">",">",">","filter_map","=","{","'ds","'",":","'2015-01-01","'","}",">",">",">","t","=","'static_babynames_partitioned'",">",">",">","hh.max_partition","(","schema='airflow","'",",","...","table_name=t",",","field='ds","'",",","filter_map=filter_map",")","'2015-01-01","'"]
code: def max_partition(
      self,
      schema: str,
      table_name: str,
      field: str | None = None,
      filter_map: dict[Any, Any] | None = None,
  ) -> Any:
      """
          Return the maximum value for all partitions with given field in a table.
  
          If only one partition key exist in the table, the key will be used as field.
          filter_map should be a partition_key:partition_value map and will be used to
          filter out partitions.
  
          :param schema: schema name.
          :param table_name: table name.
          :param field: partition key to get max partition from.
          :param filter_map: partition_key:partition_value map used for partition filtering.
  
          >>> hh = HiveMetastoreHook()
          >>> filter_map = {'ds': '2015-01-01'}
          >>> t = 'static_babynames_partitioned'
          >>> hh.max_partition(schema='airflow',\
          ... table_name=t, field='ds', filter_map=filter_map)
          '2015-01-01'
          """
      with self.metastore as client:
          table = client.get_table(dbname=schema, tbl_name=table_name)
          key_name_set = {key.name for key in table.partitionKeys}
          if len(table.partitionKeys) == 1:
              field = table.partitionKeys[0].name
          elif not field:
              raise AirflowException(
                  "Please specify the field you want the max value for."
              )
          elif field not in key_name_set:
              raise AirflowException(
                  "Provided field is not a partition key."
              )
  
          if filter_map and not set(filter_map.keys()).issubset(
              key_name_set
          ):
              raise AirflowException(
                  "Provided filter_map contains keys that are not partition key."
              )
  
          part_names = client.get_partition_names(
              schema,
              table_name,
              max_parts=HiveMetastoreHook.MAX_PART_COUNT,
          )
          part_specs = [
              client.partition_name_to_spec(part_name)
              for part_name in part_names
          ]
  
      return HiveMetastoreHook._get_max_partition_from_part_specs(
          part_specs, field, filter_map
      )
  
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 14 for calling the HiveMetastoreHook obj's underlying member method code with example usage: obj.max_partition(schema, table_name, field, filter_map) and returns: HiveMetastoreHook