'Returns the dictionary {schema : [result_set_name]}.
Datasource_type can be \'table\' or \'view\'.
Empty schema corresponds to the list of full names of the all
tables or views: <schema>.<result_set_name>.'

@classmethod
@cache_util.memoized_func(timeout=600, key=(lambda *args, **kwargs: u'db:{}:{}'.format(args[0].id, args[1])))
def fetch_result_sets(cls, db, datasource_type, force=False):

    schemas = db.inspector.get_schema_names()
    result_sets = {}
    all_result_sets = []
    for schema in schemas:
        if (datasource_type == u'table'):
            result_sets[schema] = sorted(db.inspector.get_table_names(schema))
        elif (datasource_type == u'view'):
            result_sets[schema] = sorted(db.inspector.get_view_names(schema))
        all_result_sets += [u'{}.{}'.format(schema, t) for t in result_sets[schema]]
    if all_result_sets:
        result_sets[u''] = all_result_sets
    return result_sets
