use of io.crate.planner.operators.Count in project crate by crate.
the class MergeAggregateAndCollectToCount method apply.
@Override
public Count apply(HashAggregate aggregate, Captures captures, TableStats tableStats, TransactionContext txnCtx, NodeContext nodeCtx) {
Collect collect = captures.get(collectCapture);
var countAggregate = Lists2.getOnlyElement(aggregate.aggregates());
if (countAggregate.filter() != null) {
return new Count(countAggregate, collect.relation(), collect.where().add(countAggregate.filter()));
} else {
return new Count(countAggregate, collect.relation(), collect.where());
}
}
use of io.crate.planner.operators.Count in project crate by crate.
the class MergeAggregateRenameAndCollectToCount method apply.
@Override
public LogicalPlan apply(HashAggregate aggregate, Captures captures, TableStats tableStats, TransactionContext txnCtx, NodeContext nodeCtx) {
Collect collect = captures.get(collectCapture);
Rename rename = captures.get(renameCapture);
var countAggregate = Lists2.getOnlyElement(aggregate.aggregates());
var filter = countAggregate.filter();
if (filter != null) {
var mappedFilter = FieldReplacer.replaceFields(filter, rename::resolveField);
return new Count(countAggregate, collect.relation(), collect.where().add(mappedFilter));
} else {
return new Count(countAggregate, collect.relation(), collect.where());
}
}