'Returns col name and the latest (max) partition value for a table
:param table_name: the name of the table
:type table_name: str
:param schema: schema / database / namespace
:type schema: str
:param database: database query will be run against
:type database: models.Database
:param show_first: displays the value for the first partitioning key
if there are many partitioning keys
:type show_first: bool
>>> latest_partition(\'foo_table\')
\'2018-01-01\''

@classmethod
def latest_partition(cls, table_name, schema, database, show_first=False):

    indexes = database.get_indexes(table_name, schema)
    if (len(indexes[0][u'column_names']) < 1):
        raise SupersetTemplateException(u'The    table    should    have    one    partitioned    field')
    elif ((not show_first) and (len(indexes[0][u'column_names']) > 1)):
        raise SupersetTemplateException(u'The    table    should    have    a    single    partitioned    field    to    use    this    function.    You    may    want    to    use    `presto.latest_sub_partition`')
    part_field = indexes[0][u'column_names'][0]
    sql = cls._partition_query(table_name, 1, [(part_field, True)])
    df = database.get_df(sql, schema)
    return (part_field, cls._latest_partition_from_df(df))
