As I mentioned earlier, you should be able to look at the predicates on the scan node and decide based on them alone what needs to be done about moving filters to post-aggregation. Any other filters should just work wherever they are.