'Determine which fields in joined tables haven\'t been
retrieved in the master query
@param all_fields: all requested fields (list of S3ResourceFields)
@param master_fields: all fields in the master query, a dict
{ColumnName: Field}
@return: a nested dict {TableName: {ColumnName: Field}},
additionally required left joins are stored per
table in the inner dict as "_left"'

def joined_fields(self, all_fields, master_fields):

    resource = self.resource
    table = resource.table
    tablename = table._tablename
    fields = {}
    for rfield in all_fields:
        colname = rfield.colname
        if ((colname in master_fields) or (rfield.tname == tablename)):
            continue
        tname = rfield.tname
        if (tname not in fields):
            sfields = fields[tname] = {}
            left = rfield.left
            joins = S3Joins(table)
            if left:
                [joins.add(left[tn]) for tn in left]
            sfields['_left'] = joins
        else:
            sfields = fields[tname]
        if (colname not in sfields):
            sfields[colname] = rfield.field
    return fields
