'Returns a partition query
:param table_name: the name of the table to get partitions from
:type table_name: str
:param limit: the number of partitions to be returned
:type limit: int
:param order_by: a list of tuples of field name and a boolean
that determines if that field should be sorted in descending
order
:type order_by: list of (str, bool) tuples
:param filters: a list of filters to apply
:param filters: dict of field name and filter value combinations'

@classmethod
def _partition_query(cls, table_name, limit=0, order_by=None, filters=None):

    limit_clause = (u'LIMIT    {}'.format(limit) if limit else u'')
    order_by_clause = u''
    if order_by:
        l = []
        for (field, desc) in order_by:
            l.append(((field + u'    DESC') if desc else u''))
        order_by_clause = (u'ORDER    BY    ' + u',    '.join(l))
    where_clause = u''
    if filters:
        l = []
        for (field, value) in filters.items():
            l.append(u"{field}    =    '{value}'".format(**locals()))
        where_clause = (u'WHERE    ' + u'    AND    '.join(l))
    sql = textwrap.dedent(u'                                                SHOW    PARTITIONS    FROM    {table_name}\n                                                {where_clause}\n                                                {order_by_clause}\n                                                {limit_clause}\n                                ').format(**locals())
    return sql
