def get_partitions(<EOL>self, schema, table_name, filter=None):
with self.metastore as client:<EOL><INDENT>table = client.get_table(dbname=schema, tbl_name=table_name)<EOL>if len(table.partitionKeys) == <NUM_LIT:0>:<EOL><INDENT>raise AirflowException("<STR_LIT>")<EOL><DEDENT>else:<EOL><INDENT>if filter:<EOL><INDENT>parts = client.get_partitions_by_filter(<EOL>db_name=schema, tbl_name=table_name,<EOL>filter=filter, max_parts=HiveMetastoreHook.MAX_PART_COUNT)<EOL><DEDENT>else:<EOL><INDENT>parts = client.get_partitions(<EOL>db_name=schema, tbl_name=table_name,<EOL>max_parts=HiveMetastoreHook.MAX_PART_COUNT)<EOL><DEDENT>pnames = [p.name for p in table.partitionKeys]<EOL>return [dict(zip(pnames, p.values)) for p in parts]<EOL><DEDENT><DEDENT>
Returns a list of all partitions in a table. Works only
for tables with less than 32767 (java short max val).
For subpartitioned table, the number might easily exceed this.

>>> hh = HiveMetastoreHook()
>>> t = 'static_babynames_partitioned'
>>> parts = hh.get_partitions(schema='airflow', table_name=t)
>>> len(parts)
1
>>> parts
[{'ds': '2015-01-01'}]