def METHOD_NAME (request, data_by_deed, sql_context):
    def aggregate_by_domain (acc, item): 
        domain = urlparse(item ['uri']).netloc
        if (domain not in acc):
            acc [domain] = 0
        acc[domain] += 1
        return acc
    def flat (deed): 
        return map (lambda domain: (deed [0], domain, deed [1][domain]), deed [1])
        #ret = []
        #for domain in deed [1]:
        #    ret.append ((deed [0], domain, deed [1][domain]))
        #return ret;
    lns = data_by_deed.aggregateByKey ({}, aggregate_by_domain, lambda s, d: s + d).flatMap (lambda x: flat (x))
    return sql_context.createDataFrame (lns, ["license", "domain", "count"]);