Let history lookahead in the pipeline for head, tail count, grep and random to implement them at the query level