Class PushCountQueryAndTagsToSource


public class PushCountQueryAndTagsToSource extends PhysicalOptimizerRules.OptimizerRule<AggregateExec>
Pushes count aggregations on top of query and tags to source. Will transform:
  Aggregate (count(*) by x)
  └── Eval (x = round_to)
      └── Query [query + tags]
  
into:
  Filter (count > 0)
  └── StatsQuery [count with query + tags]
  
Where the filter is needed since the original Aggregate would not produce buckets with count = 0. If there's more than one query on the query builder, and both filters are on the same field, this rule will also attempt to merge them before pushing. This can happen due to an external ESFilter (i.e., outside the ES|QL query), or simply to a previously pushed down WHERE clause. If the queries cannot be merged, the rule will not be applied.