airflow/hooks/hive_hooks.py
def get_partitions(
            self, schema, table_name, filter=None):
        """
        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'}]
        """
        with self.metastore as client:
            table = client.get_table(dbname=schema, tbl_name=table_name)
            if len(table.partitionKeys) == 0:
                raise AirflowException("The table isn't partitioned")
            else:
                if filter:
                    parts = client.get_partitions_by_filter(
                        db_name=schema, tbl_name=table_name,
                        filter=filter, max_parts=HiveMetastoreHook.MAX_PART_COUNT)
                else:
                    parts = client.get_partitions(
                        db_name=schema, tbl_name=table_name,
                        max_parts=HiveMetastoreHook.MAX_PART_COUNT)

                pnames = [p.name for p in table.partitionKeys]
                return [dict(zip(pnames, p.values)) for p in parts]
def get_partitions(
            self, schema, table_name, filter=None):
        """
        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'}]
        """
        with self.metastore as client:
            table = client.get_table(dbname=schema, tbl_name=table_name)
            if len(table.partitionKeys) == 0:
                raise AirflowException("The table isn't partitioned")
            else:
                if filter:
                    parts = client.get_partitions_by_filter(
                        db_name=schema, tbl_name=table_name,
                        filter=filter, max_parts=HiveMetastoreHook.MAX_PART_COUNT)
                else:
                    parts = client.get_partitions(
                        db_name=schema, tbl_name=table_name,
                        max_parts=HiveMetastoreHook.MAX_PART_COUNT)

                pnames = [p.name for p in table.partitionKeys]
                return [dict(zip(pnames, p.values)) for p in parts]
def get_partitions ( self , schema , table_name , filter = None ) : with self . metastore as client : table = client . get_table ( dbname = schema , tbl_name = table_name ) if len ( table . partitionKeys ) == 0 : raise AirflowException ( "The table isn't partitioned" ) else : if filter : parts = client . get_partitions_by_filter ( db_name = schema , tbl_name = table_name , filter = filter , max_parts = HiveMetastoreHook . MAX_PART_COUNT ) else : parts = client . get_partitions ( db_name = schema , tbl_name = table_name , max_parts = HiveMetastoreHook . MAX_PART_COUNT ) pnames = [ p . name for p in table . partitionKeys ] return [ dict ( zip ( pnames , p . values ) ) for p in parts ]
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'}]
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 .