instead of doing this handoff of the boolean value to the aggregation, you should just do it inline with the limit. So just do:

PlanNode rewrittenSource = planRewriter.rewrite(source.getSource(), context);

since you already know at this point the the source is an Aggregation that you want to omit.