def check_existing_by_datasetid(syn, datasetids, file_view_id):
    """Check a file view that has a 'datasetid' column to see which datasetids exist.

    """
    res = syn.tableQuery('select id,datasetid from %s' % (file_view_id,))
    d = res.asDataFrame()
    existing_datasetids = set(d.datasetid.tolist())
    given_datasetids = set(datasetids)
    return {'exists': given_datasetids.intersection(existing_datasetids),
        'not_exists': given_datasetids.difference(existing_datasetids)}
