Fix "Only deterministic expressions may be considered for rewrite" exception when processing JOINs that have ORDER BY rand()