'Returns the number of distinct groups for the given query grouped by the
fields in group_by.'

def get_num_groups(self, query, group_by):

    (sql, params) = self._get_num_groups_sql(query, group_by)
    cursor = readonly_connection.connection().cursor()
    cursor.execute(sql, params)
    return self._cursor_rowcount(cursor)
