nodes: 0, module; 1, function_definition; 2, function_name:_partition_query; 3, parameters; 4, block; 5, identifier:cls; 6, identifier:table_name; 7, default_parameter; 8, default_parameter; 9, default_parameter; 10, expression_statement; 11, expression_statement; 12, expression_statement; 13, if_statement; 14, expression_statement; 15, if_statement; 16, expression_statement; 17, return_statement; 18, identifier:limit; 19, integer:0; 20, identifier:order_by; 21, None; 22, identifier:filters; 23, None; 24, comment:"""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: dict of field name and filter value combinations
          """; 25, assignment; 26, assignment; 27, identifier:order_by; 28, block; 29, assignment; 30, identifier:filters; 31, block; 32, assignment; 33, identifier:sql; 34, identifier:limit_clause; 35, conditional_expression:'LIMIT {}'.format(limit) if limit else ''; 36, identifier:order_by_clause; 37, string; 38, expression_statement; 39, comment:# noqa: E741; 40, for_statement; 41, expression_statement; 42, identifier:where_clause; 43, string; 44, expression_statement; 45, comment:# noqa: E741; 46, for_statement; 47, expression_statement; 48, identifier:sql; 49, call; 50, call; 51, identifier:limit; 52, string; 53, assignment; 54, pattern_list; 55, identifier:order_by; 56, block; 57, assignment; 58, assignment; 59, pattern_list; 60, call; 61, block; 62, assignment; 63, attribute; 64, argument_list; 65, attribute; 66, argument_list; 67, identifier:l; 68, list; 69, identifier:field; 70, identifier:desc; 71, expression_statement; 72, identifier:order_by_clause; 73, binary_operator:'ORDER BY ' + ', '.join(l); 74, identifier:l; 75, list; 76, identifier:field; 77, identifier:value; 78, attribute; 79, argument_list; 80, expression_statement; 81, identifier:where_clause; 82, binary_operator:'WHERE ' + ' AND '.join(l); 83, identifier:textwrap; 84, identifier:dedent; 85, comment:f"""\
              SELECT * FROM "{table_name}$partitions"
  
              {where_clause}
              {order_by_clause}
              {limit_clause}
          """; 86, string; 87, identifier:format; 88, identifier:limit; 89, call; 90, string; 91, call; 92, identifier:filters; 93, identifier:items; 94, call; 95, string; 96, call; 97, string_content:LIMIT {}; 98, attribute; 99, argument_list; 100, string_content:ORDER BY; 101, attribute; 102, argument_list; 103, attribute; 104, argument_list; 105, string_content:WHERE; 106, attribute; 107, argument_list; 108, identifier:l; 109, identifier:append; 110, conditional_expression:field + ' DESC' if desc else ''; 111, string; 112, identifier:join; 113, identifier:l; 114, identifier:l; 115, identifier:append; 116, string:f"{field} = '{value}'"; 117, string; 118, identifier:join; 119, identifier:l; 120, binary_operator:field + ' DESC'; 121, identifier:desc; 122, string; 123, string_content:,; 124, string_content:AND; 125, identifier:field; 126, string; 127, string_content:DESC
code: def _partition_query(
              cls, table_name, limit=0, order_by=None, filters=None):
          """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: dict of field name and filter value combinations
          """
          limit_clause = 'LIMIT {}'.format(limit) if limit else ''
          order_by_clause = ''
          if order_by:
              l = []  # noqa: E741
              for field, desc in order_by:
                  l.append(field + ' DESC' if desc else '')
              order_by_clause = 'ORDER BY ' + ', '.join(l)
  
          where_clause = ''
          if filters:
              l = []  # noqa: E741
              for field, value in filters.items():
                  l.append(f"{field} = '{value}'")
              where_clause = 'WHERE ' + ' AND '.join(l)
  
          sql = textwrap.dedent(f"""\
              SELECT * FROM "{table_name}$partitions"
  
              {where_clause}
              {order_by_clause}
              {limit_clause}
          """)
          return sql