'Returns the results of an Impala SELECT histogram() FROM query for a given column or nested type.
Assumes that the column/nested type is scalar.'

def get_histogram(self, database, table, column, nested=None):

    results = []
    hql = self.get_histogram_query(database, table, column, nested)
    query = hql_query(hql)
    handle = self.execute_and_wait(query, timeout_sec=5.0)
    if handle:
        result = self.fetch(handle)
        try:
            histogram = list(result.rows())[0][0]
            unique_values = set(histogram.split(',    '))
            results = list(unique_values)
        except IndexError as e:
            LOG.warn(('Failed    to    get    histogram    results,    result    set    has    unexpected    format:    %s' % smart_str(e)))
        finally:
            self.close(handle)
    return results
