use of io.crate.planner.operators.Rename in project crate by crate.
the class MoveFilterBeneathRename method apply.
@Override
public LogicalPlan apply(Filter plan, Captures captures, TableStats tableStats, TransactionContext txnCtx, NodeContext nodeCtx) {
Rename rename = captures.get(renameCapture);
Filter newFilter = new Filter(rename.source(), FieldReplacer.replaceFields(plan.query(), rename::resolveField));
return rename.replaceSources(List.of(newFilter));
}
use of io.crate.planner.operators.Rename in project crate by crate.
the class MoveOrderBeneathRename method apply.
@Override
public LogicalPlan apply(Order plan, Captures captures, TableStats tableStats, TransactionContext txnCtx, NodeContext nodeCtx) {
Rename rename = captures.get(renameCapture);
Function<? super Symbol, ? extends Symbol> mapField = FieldReplacer.bind(rename::resolveField);
OrderBy mappedOrderBy = plan.orderBy().map(mapField);
if (rename.source().outputs().containsAll(mappedOrderBy.orderBySymbols())) {
Order newOrder = new Order(rename.source(), mappedOrderBy);
return rename.replaceSources(List.of(newOrder));
} else {
return null;
}
}
use of io.crate.planner.operators.Rename 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());
}
}