queries: implement pred_to_pattern